[PATCH 1/4] httpd: do not send useless Date header

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


In RFC 2616 section 14.18 said that sever MUST send Date header https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18
But in fact the header is often ignored and makes sense only for caching by age `Cache-Control: max-age=21600` when server clock is wrong. But BusyBox have support of cache aging and it makes sense only for generated content. We can use ETag instead.
In the same time the Date eats power, CPU and network resources which are critical for embedded systems.

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

diff --git a/networking/httpd.c b/networking/httpd.c
index f4e95768f..ff25b4c5b 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1071,14 +1071,10 @@ static void send_headers(unsigned responseNum)
 	 * always fit into those kbytes.
 	 */
 
-	strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, &tm));
-	/* ^^^ using gmtime_r() instead of gmtime() to not use static data */
 	len = sprintf(iobuf,
 			"HTTP/1.0 %u %s\r\n"
-			"Date: %s\r\n"
 			"Connection: close\r\n",
-			responseNum, responseString,
-			date_str
+			responseNum, responseString
 	);
 
 	if (responseNum != HTTP_OK || found_mime_type) {
-- 
2.25.1



More information about the busybox mailing list