diff options
| author | Sergey Ponomarev <stokito@gmail.com> | 2020-08-09 01:23:32 +0300 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-08-15 23:04:49 +0200 |
| commit | 68f75bb9cecbed3a1bed29219de77373fcba7a88 (patch) | |
| tree | 8671ff74735d31440acfc8260a994e23635d92c4 | |
| parent | b414cdf5b4a3950ac09b630d0d8b7d2844a7cf81 (diff) | |
| download | busybox-w32-68f75bb9cecbed3a1bed29219de77373fcba7a88.tar.gz busybox-w32-68f75bb9cecbed3a1bed29219de77373fcba7a88.tar.bz2 busybox-w32-68f75bb9cecbed3a1bed29219de77373fcba7a88.zip | |
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.c | 18 |
1 files changed, 16 insertions, 2 deletions
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 @@ | |||
| 214 | //config: help | 214 | //config: help |
| 215 | //config: Makes httpd send files using GZIP content encoding if the | 215 | //config: Makes httpd send files using GZIP content encoding if the |
| 216 | //config: client supports it and a pre-compressed <file>.gz exists. | 216 | //config: client supports it and a pre-compressed <file>.gz exists. |
| 217 | //config: | ||
| 218 | //config:config FEATURE_HTTPD_DATE | ||
| 219 | //config: bool "Add Date header to response" | ||
| 220 | //config: default y | ||
| 221 | //config: depends on HTTPD | ||
| 222 | //config: help | ||
| 223 | //config: RFC2616 says that server MUST add Date header to response. | ||
| 224 | //config: But it is almost useless and can be omitted. | ||
| 217 | 225 | ||
| 218 | //applet:IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) | 226 | //applet:IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
| 219 | 227 | ||
| @@ -1071,14 +1079,20 @@ static void send_headers(unsigned responseNum) | |||
| 1071 | * always fit into those kbytes. | 1079 | * always fit into those kbytes. |
| 1072 | */ | 1080 | */ |
| 1073 | 1081 | ||
| 1082 | #if ENABLE_FEATURE_HTTPD_DATE | ||
| 1074 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, &tm)); | 1083 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, &tm)); |
| 1075 | /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ | 1084 | /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ |
| 1085 | #endif | ||
| 1076 | len = sprintf(iobuf, | 1086 | len = sprintf(iobuf, |
| 1077 | "HTTP/1.1 %u %s\r\n" | 1087 | "HTTP/1.1 %u %s\r\n" |
| 1088 | #if ENABLE_FEATURE_HTTPD_DATE | ||
| 1078 | "Date: %s\r\n" | 1089 | "Date: %s\r\n" |
| 1090 | #endif | ||
| 1079 | "Connection: close\r\n", | 1091 | "Connection: close\r\n", |
| 1080 | responseNum, responseString, | 1092 | responseNum, responseString |
| 1081 | date_str | 1093 | #if ENABLE_FEATURE_HTTPD_DATE |
| 1094 | ,date_str | ||
| 1095 | #endif | ||
| 1082 | ); | 1096 | ); |
| 1083 | 1097 | ||
| 1084 | if (responseNum != HTTP_OK || found_mime_type) { | 1098 | if (responseNum != HTTP_OK || found_mime_type) { |
