]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
handle headers when replying a 304 following rfc7234
authorGiovanni Bechis <gbechis@apache.org>
Wed, 9 Sep 2020 14:43:07 +0000 (14:43 +0000)
committerGiovanni Bechis <gbechis@apache.org>
Wed, 9 Sep 2020 14:43:07 +0000 (14:43 +0000)
as discussed in bz 61820

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1881590 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_filters.c

index 016bcf5e9708c01e4efc3bb82788bb363fde9488..a9d460de0359cfa18f8c1b005929aeda34ac265a 100644 (file)
@@ -1427,25 +1427,21 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
     h.bb = b2;
 
     if (r->status == HTTP_NOT_MODIFIED) {
-        apr_table_do((int (*)(void *, const char *, const char *)) form_header_field,
-                     (void *) &h, r->headers_out,
-                     "Connection",
-                     "Keep-Alive",
-                     "ETag",
-                     "Content-Location",
-                     "Expires",
-                     "Cache-Control",
-                     "Vary",
-                     "Warning",
-                     "WWW-Authenticate",
-                     "Proxy-Authenticate",
-                     "Set-Cookie",
-                     "Set-Cookie2",
-                     NULL);
-    }
-    else {
-        send_all_header_fields(&h, r);
-    }
+      /*
+       * List of headers that must not be updated on a 304 (or 206 partial content)
+       * https://tools.ietf.org/id/draft-ietf-httpbis-cache-08.txt
+       */
+      apr_table_unset(r->headers_out, "Content_Encoding");
+      apr_table_unset(r->headers_out, "Content_Length");
+      apr_table_unset(r->headers_out, "Content_MD5");
+      apr_table_unset(r->headers_out, "Content_Range");
+      apr_table_unset(r->headers_out, "ETag");
+      apr_table_unset(r->headers_out, "TE");
+      apr_table_unset(r->headers_out, "Trailer");
+      apr_table_unset(r->headers_out, "Transfer_Encoding");
+      apr_table_unset(r->headers_out, "Upgrade");
+    }
+    send_all_header_fields(&h, r);
 
     terminate_header(b2);