diff options
author | Sergey Ponomarev <stokito@gmail.com> | 2020-08-09 01:23:31 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-08-15 22:51:14 +0200 |
commit | b414cdf5b4a3950ac09b630d0d8b7d2844a7cf81 (patch) | |
tree | aec42c9167a55c46dafcd55376499ba585f5cd8c | |
parent | 1a5d6fcbb5e606ab4acdf22afa26361a25f1d43b (diff) | |
download | busybox-w32-b414cdf5b4a3950ac09b630d0d8b7d2844a7cf81.tar.gz busybox-w32-b414cdf5b4a3950ac09b630d0d8b7d2844a7cf81.tar.bz2 busybox-w32-b414cdf5b4a3950ac09b630d0d8b7d2844a7cf81.zip |
httpd: Update to HTTP/1.1
HTTP v1.1 was released in 1999 year and it's time to update BB HTTPD.
Browsers may behave badly with HTTP/1.0
E.g. Chrome does not send the If-None-Match header with ETag.
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/httpd.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index f4e95768f..9141442c8 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -269,7 +269,7 @@ | |||
269 | 269 | ||
270 | static const char DEFAULT_PATH_HTTPD_CONF[] ALIGN1 = "/etc"; | 270 | static const char DEFAULT_PATH_HTTPD_CONF[] ALIGN1 = "/etc"; |
271 | static const char HTTPD_CONF[] ALIGN1 = "httpd.conf"; | 271 | static const char HTTPD_CONF[] ALIGN1 = "httpd.conf"; |
272 | static const char HTTP_200[] ALIGN1 = "HTTP/1.0 200 OK\r\n"; | 272 | static const char HTTP_200[] ALIGN1 = "HTTP/1.1 200 OK\r\n"; |
273 | static const char index_html[] ALIGN1 = "index.html"; | 273 | static const char index_html[] ALIGN1 = "index.html"; |
274 | 274 | ||
275 | typedef struct has_next_ptr { | 275 | typedef struct has_next_ptr { |
@@ -1074,7 +1074,7 @@ static void send_headers(unsigned responseNum) | |||
1074 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, &tm)); | 1074 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, &tm)); |
1075 | /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ | 1075 | /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ |
1076 | len = sprintf(iobuf, | 1076 | len = sprintf(iobuf, |
1077 | "HTTP/1.0 %u %s\r\n" | 1077 | "HTTP/1.1 %u %s\r\n" |
1078 | "Date: %s\r\n" | 1078 | "Date: %s\r\n" |
1079 | "Connection: close\r\n", | 1079 | "Connection: close\r\n", |
1080 | responseNum, responseString, | 1080 | responseNum, responseString, |
@@ -1099,7 +1099,7 @@ static void send_headers(unsigned responseNum) | |||
1099 | #endif | 1099 | #endif |
1100 | if (responseNum == HTTP_MOVED_TEMPORARILY) { | 1100 | if (responseNum == HTTP_MOVED_TEMPORARILY) { |
1101 | /* Responding to "GET /dir" with | 1101 | /* Responding to "GET /dir" with |
1102 | * "HTTP/1.0 302 Found" "Location: /dir/" | 1102 | * "HTTP/1.1 302 Found" "Location: /dir/" |
1103 | * - IOW, asking them to repeat with a slash. | 1103 | * - IOW, asking them to repeat with a slash. |
1104 | * Here, overflow IS possible, can't use sprintf: | 1104 | * Here, overflow IS possible, can't use sprintf: |
1105 | * mkdir test | 1105 | * mkdir test |
@@ -1409,7 +1409,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post | |||
1409 | count = safe_read(fromCgi_rd, rbuf + out_cnt, IOBUF_SIZE - 8); | 1409 | count = safe_read(fromCgi_rd, rbuf + out_cnt, IOBUF_SIZE - 8); |
1410 | if (count <= 0) { | 1410 | if (count <= 0) { |
1411 | /* eof (or error) and there was no "HTTP", | 1411 | /* eof (or error) and there was no "HTTP", |
1412 | * send "HTTP/1.0 200 OK\r\n", then send received data */ | 1412 | * send "HTTP/1.1 200 OK\r\n", then send received data */ |
1413 | if (out_cnt) { | 1413 | if (out_cnt) { |
1414 | full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1); | 1414 | full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1); |
1415 | full_write(STDOUT_FILENO, rbuf, out_cnt); | 1415 | full_write(STDOUT_FILENO, rbuf, out_cnt); |
@@ -1420,10 +1420,10 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post | |||
1420 | count = 0; | 1420 | count = 0; |
1421 | /* "Status" header format is: "Status: 302 Redirected\r\n" */ | 1421 | /* "Status" header format is: "Status: 302 Redirected\r\n" */ |
1422 | if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) { | 1422 | if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) { |
1423 | /* send "HTTP/1.0 " */ | 1423 | /* send "HTTP/1.1 " */ |
1424 | if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9) | 1424 | if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9) |
1425 | break; | 1425 | break; |
1426 | /* skip "Status: " (including space, sending "HTTP/1.0 NNN" is wrong) */ | 1426 | /* skip "Status: " (including space, sending "HTTP/1.1 NNN" is wrong) */ |
1427 | rbuf += 8; | 1427 | rbuf += 8; |
1428 | count = out_cnt - 8; | 1428 | count = out_cnt - 8; |
1429 | out_cnt = -1; /* buffering off */ | 1429 | out_cnt = -1; /* buffering off */ |
@@ -1439,7 +1439,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post | |||
1439 | full_write(s, "Content-type: text/plain\r\n\r\n", 28); | 1439 | full_write(s, "Content-type: text/plain\r\n\r\n", 28); |
1440 | } | 1440 | } |
1441 | * Counter-example of valid CGI without Content-type: | 1441 | * Counter-example of valid CGI without Content-type: |
1442 | * echo -en "HTTP/1.0 302 Found\r\n" | 1442 | * echo -en "HTTP/1.1 302 Found\r\n" |
1443 | * echo -en "Location: http://www.busybox.net\r\n" | 1443 | * echo -en "Location: http://www.busybox.net\r\n" |
1444 | * echo -en "\r\n" | 1444 | * echo -en "\r\n" |
1445 | */ | 1445 | */ |
@@ -1546,7 +1546,7 @@ static void send_cgi_and_exit( | |||
1546 | /* (Older versions of bbox seem to do some decoding) */ | 1546 | /* (Older versions of bbox seem to do some decoding) */ |
1547 | setenv1("QUERY_STRING", g_query); | 1547 | setenv1("QUERY_STRING", g_query); |
1548 | putenv((char*)"SERVER_SOFTWARE=busybox httpd/"BB_VER); | 1548 | putenv((char*)"SERVER_SOFTWARE=busybox httpd/"BB_VER); |
1549 | putenv((char*)"SERVER_PROTOCOL=HTTP/1.0"); | 1549 | putenv((char*)"SERVER_PROTOCOL=HTTP/1.1"); |
1550 | putenv((char*)"GATEWAY_INTERFACE=CGI/1.1"); | 1550 | putenv((char*)"GATEWAY_INTERFACE=CGI/1.1"); |
1551 | /* Having _separate_ variables for IP and port defeats | 1551 | /* Having _separate_ variables for IP and port defeats |
1552 | * the purpose of having socket abstraction. Which "port" | 1552 | * the purpose of having socket abstraction. Which "port" |