]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_http2: fix logic for non-proxy Server and Date response headers.
authorYann Ylavic <ylavic@apache.org>
Thu, 25 Nov 2021 15:57:21 +0000 (15:57 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 25 Nov 2021 15:57:21 +0000 (15:57 +0000)
First error was in r1890564 where the test for !PROXYREQ_NONE was replaced by
PROXYREQ_RESPONSE (which is never the case besides the fake proxy origin
request) so a mod_h2 PR tried to fix that but the logic is now incorrect.

Let's finally use the same logic as ap_basic_http_header().

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

modules/http2/h2_c2_filter.c

index ed34db681deccf57f1470ddc9dfd1381e1dda7e0..9df138161fce4bac1c7fa1d55fe421fc38fd2935 100644 (file)
@@ -245,16 +245,16 @@ static h2_headers *create_response(request_rec *r)
      * keep the set-by-proxy server and date headers, otherwise
      * generate a new server header / date header
      */
-    if (r->proxyreq != PROXYREQ_NONE
-        && !apr_table_get(r->headers_out, "Date")) {
+    if (r->proxyreq == PROXYREQ_NONE
+        || !apr_table_get(r->headers_out, "Date")) {
         char *date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
         ap_recent_rfc822_date(date, r->request_time);
         apr_table_setn(r->headers_out, "Date", date );
     }
-    if (r->proxyreq != PROXYREQ_NONE
-        && !apr_table_get(r->headers_out, "Server")) {
+    if (r->proxyreq == PROXYREQ_NONE
+        || !apr_table_get(r->headers_out, "Server")) {
         const char *us = ap_get_server_banner();
-        if (us) {
+        if (us && *us) {
             apr_table_setn(r->headers_out, "Server", us);
         }
     }