summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Ponomarev2020-08-09 01:23:32 +0300
committerDenys Vlasenko2020-08-15 23:04:49 +0200
commit68f75bb9cecbed3a1bed29219de77373fcba7a88 (patch)
tree8671ff74735d31440acfc8260a994e23635d92c4
parentb414cdf5b4a3950ac09b630d0d8b7d2844a7cf81 (diff)
downloadbusybox-68f75bb9cecbed3a1bed29219de77373fcba7a88.zip
busybox-68f75bb9cecbed3a1bed29219de77373fcba7a88.tar.gz
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 <stokito@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/httpd.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 9141442..a1f841a 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 <file>.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) {