diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-12-17 21:01:15 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-12-17 21:02:16 +0100 |
| commit | b720629dfec0e8e991e75b751dad215af2bc657f (patch) | |
| tree | dd760c8b8b7b1e55f431139f7f4a90c4e0ae3bd3 | |
| parent | 70683faf380681a11e16a85090162581aed55d73 (diff) | |
| download | busybox-w32-b720629dfec0e8e991e75b751dad215af2bc657f.tar.gz busybox-w32-b720629dfec0e8e991e75b751dad215af2bc657f.tar.bz2 busybox-w32-b720629dfec0e8e991e75b751dad215af2bc657f.zip | |
httpd: do not send Last-Modified / ETag / Content-Length for error pages
function old new delta
send_headers 713 701 -12
send_headers_and_exit 20 34 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | networking/httpd.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 4def1b6fc..1ba1d1063 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
| @@ -1222,29 +1222,17 @@ static void send_headers(unsigned responseNum) | |||
| 1222 | // (NB: standards do not define "Transfer-Length:" _header_, | 1222 | // (NB: standards do not define "Transfer-Length:" _header_, |
| 1223 | // transfer-length above is just a concept). | 1223 | // transfer-length above is just a concept). |
| 1224 | 1224 | ||
| 1225 | #if ENABLE_FEATURE_HTTPD_RANGES \ | ||
| 1226 | || ENABLE_FEATURE_HTTPD_LAST_MODIFIED \ | ||
| 1227 | || ENABLE_FEATURE_HTTPD_ETAG | ||
| 1228 | len += sprintf(iobuf + len, | 1225 | len += sprintf(iobuf + len, |
| 1229 | # if ENABLE_FEATURE_HTTPD_RANGES | 1226 | #if ENABLE_FEATURE_HTTPD_RANGES |
| 1230 | "Accept-Ranges: bytes\r\n" | 1227 | "Accept-Ranges: bytes\r\n" |
| 1231 | # endif | 1228 | #endif |
| 1232 | # if ENABLE_FEATURE_HTTPD_LAST_MODIFIED | 1229 | #if ENABLE_FEATURE_HTTPD_LAST_MODIFIED |
| 1233 | "Last-Modified: %s\r\n" | 1230 | "Last-Modified: %s\r\n" |
| 1234 | # endif | 1231 | #endif |
| 1235 | # if ENABLE_FEATURE_HTTPD_ETAG | 1232 | #if ENABLE_FEATURE_HTTPD_ETAG |
| 1236 | "ETag: %s\r\n" | 1233 | "ETag: %s\r\n" |
| 1237 | # endif | ||
| 1238 | # if ENABLE_FEATURE_HTTPD_LAST_MODIFIED | ||
| 1239 | , date_str | ||
| 1240 | # endif | ||
| 1241 | # if ENABLE_FEATURE_HTTPD_ETAG | ||
| 1242 | , G.etag | ||
| 1243 | # endif | ||
| 1244 | #endif | 1234 | #endif |
| 1245 | ); | 1235 | |
| 1246 | if (!infoString) { | ||
| 1247 | len += sprintf(iobuf + len, | ||
| 1248 | /* Because of 4.4 (5), we can forgo sending of "Content-Length" | 1236 | /* Because of 4.4 (5), we can forgo sending of "Content-Length" |
| 1249 | * since we close connection afterwards, but it helps clients | 1237 | * since we close connection afterwards, but it helps clients |
| 1250 | * to e.g. estimate download times, show progress bars etc. | 1238 | * to e.g. estimate download times, show progress bars etc. |
| @@ -1252,9 +1240,14 @@ static void send_headers(unsigned responseNum) | |||
| 1252 | * but de-facto standard is to send it (see comment below). | 1240 | * but de-facto standard is to send it (see comment below). |
| 1253 | */ | 1241 | */ |
| 1254 | "Content-Length: %"OFF_FMT"u\r\n", | 1242 | "Content-Length: %"OFF_FMT"u\r\n", |
| 1243 | #if ENABLE_FEATURE_HTTPD_LAST_MODIFIED | ||
| 1244 | date_str, | ||
| 1245 | #endif | ||
| 1246 | #if ENABLE_FEATURE_HTTPD_ETAG | ||
| 1247 | G.etag, | ||
| 1248 | #endif | ||
| 1255 | file_size | 1249 | file_size |
| 1256 | ); | 1250 | ); |
| 1257 | } | ||
| 1258 | } | 1251 | } |
| 1259 | 1252 | ||
| 1260 | /* This should be "Transfer-Encoding", not "Content-Encoding": | 1253 | /* This should be "Transfer-Encoding", not "Content-Encoding": |
| @@ -1297,6 +1290,7 @@ static void send_headers_and_exit(int responseNum) NORETURN; | |||
| 1297 | static void send_headers_and_exit(int responseNum) | 1290 | static void send_headers_and_exit(int responseNum) |
| 1298 | { | 1291 | { |
| 1299 | IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) | 1292 | IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) |
| 1293 | file_size = -1; /* no Last-Modified:, ETag:, Content-Length: */ | ||
| 1300 | send_headers(responseNum); | 1294 | send_headers(responseNum); |
| 1301 | log_and_exit(); | 1295 | log_and_exit(); |
| 1302 | } | 1296 | } |
