From 68f75bb9cecbed3a1bed29219de77373fcba7a88 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sun, 9 Aug 2020 01:23:32 +0300 Subject: httpd: Don't add Date header to response RFC 2616 sec. 14.18 says that server MUST send Date header. But in fact the header make sense only for Cache-Control and can be omitted. In the same time the Date eats power, CPU and network resources which are critical for embedded systems. Signed-off-by: Sergey Ponomarev Signed-off-by: Denys Vlasenko --- networking/httpd.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'networking') diff --git a/networking/httpd.c b/networking/httpd.c index 9141442c8..a1f841aa8 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -214,6 +214,14 @@ //config: help //config: Makes httpd send files using GZIP content encoding if the //config: client supports it and a pre-compressed .gz exists. +//config: +//config:config FEATURE_HTTPD_DATE +//config: bool "Add Date header to response" +//config: default y +//config: depends on HTTPD +//config: help +//config: RFC2616 says that server MUST add Date header to response. +//config: But it is almost useless and can be omitted. //applet:IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) @@ -1071,14 +1079,20 @@ static void send_headers(unsigned responseNum) * always fit into those kbytes. */ +#if ENABLE_FEATURE_HTTPD_DATE strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, &tm)); /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ +#endif len = sprintf(iobuf, "HTTP/1.1 %u %s\r\n" +#if ENABLE_FEATURE_HTTPD_DATE "Date: %s\r\n" +#endif "Connection: close\r\n", - responseNum, responseString, - date_str + responseNum, responseString +#if ENABLE_FEATURE_HTTPD_DATE + ,date_str +#endif ); if (responseNum != HTTP_OK || found_mime_type) { -- cgit v1.2.3