[PATCH 4/4] httpd: update to HTTP/1.1

Sergey Ponomarev stokito at gmail.com
Thu Jul 9 22:42:19 UTC 2020


The ETag header was introduced in HTTP v1.1 in 1999 year. Chrome not send the If-None-Match header if server uses old HTTP/1.0 protocol.

Signed-off-by: Sergey Ponomarev <stokito at gmail.com>
---
 networking/httpd.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index 50a837229..c713e61d7 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -277,7 +277,7 @@
 
 static const char DEFAULT_PATH_HTTPD_CONF[] ALIGN1 = "/etc";
 static const char HTTPD_CONF[] ALIGN1 = "httpd.conf";
-static const char HTTP_200[] ALIGN1 = "HTTP/1.0 200 OK\r\n";
+static const char HTTP_200[] ALIGN1 = "HTTP/1.1 200 OK\r\n";
 static const char index_html[] ALIGN1 = "index.html";
 
 typedef struct has_next_ptr {
@@ -1086,7 +1086,7 @@ static void send_headers(unsigned responseNum)
 	 */
 
 	len = sprintf(iobuf,
-			"HTTP/1.0 %u %s\r\n"
+			"HTTP/1.1 %u %s\r\n"
 			"Connection: close\r\n",
 			responseNum, responseString
 	);
@@ -1109,7 +1109,7 @@ static void send_headers(unsigned responseNum)
 #endif
 	if (responseNum == HTTP_MOVED_TEMPORARILY) {
 		/* Responding to "GET /dir" with
-		 * "HTTP/1.0 302 Found" "Location: /dir/"
+		 * "HTTP/1.1 302 Found" "Location: /dir/"
 		 * - IOW, asking them to repeat with a slash.
 		 * Here, overflow IS possible, can't use sprintf:
 		 * mkdir test
@@ -1423,7 +1423,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
 				count = safe_read(fromCgi_rd, rbuf + out_cnt, IOBUF_SIZE - 8);
 				if (count <= 0) {
 					/* eof (or error) and there was no "HTTP",
-					 * send "HTTP/1.0 200 OK\r\n", then send received data */
+					 * send "HTTP/1.1 200 OK\r\n", then send received data */
 					if (out_cnt) {
 						full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1);
 						full_write(STDOUT_FILENO, rbuf, out_cnt);
@@ -1434,10 +1434,10 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
 				count = 0;
 				/* "Status" header format is: "Status: 302 Redirected\r\n" */
 				if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) {
-					/* send "HTTP/1.0 " */
+					/* send "HTTP/1.1 " */
 					if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9)
 						break;
-					/* skip "Status: " (including space, sending "HTTP/1.0  NNN" is wrong) */
+					/* skip "Status: " (including space, sending "HTTP/1.1  NNN" is wrong) */
 					rbuf += 8;
 					count = out_cnt - 8;
 					out_cnt = -1; /* buffering off */
@@ -1453,7 +1453,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
 						full_write(s, "Content-type: text/plain\r\n\r\n", 28);
 					}
 					 * Counter-example of valid CGI without Content-type:
-					 * echo -en "HTTP/1.0 302 Found\r\n"
+					 * echo -en "HTTP/1.1 302 Found\r\n"
 					 * echo -en "Location: http://www.busybox.net\r\n"
 					 * echo -en "\r\n"
 					 */
@@ -1560,7 +1560,7 @@ static void send_cgi_and_exit(
 	/* (Older versions of bbox seem to do some decoding) */
 	setenv1("QUERY_STRING", g_query);
 	putenv((char*)"SERVER_SOFTWARE=busybox httpd/"BB_VER);
-	putenv((char*)"SERVER_PROTOCOL=HTTP/1.0");
+	putenv((char*)"SERVER_PROTOCOL=HTTP/1.1");
 	putenv((char*)"GATEWAY_INTERFACE=CGI/1.1");
 	/* Having _separate_ variables for IP and port defeats
 	 * the purpose of having socket abstraction. Which "port"
-- 
2.25.1



More information about the busybox mailing list