]> granicus.if.org Git - apache/commitdiff
If a Date response header was already set in the headers array,
authorGraham Leggett <minfrin@apache.org>
Tue, 15 Apr 2003 17:39:43 +0000 (17:39 +0000)
committerGraham Leggett <minfrin@apache.org>
Tue, 15 Apr 2003 17:39:43 +0000 (17:39 +0000)
this value was ignored in favour of the current time. This meant
that Date headers on proxied requests where rewritten when they
should not have been.
PR: 14376
Obtained from:
Submitted by:
Reviewed by:

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

CHANGES
modules/http/http_protocol.c

diff --git a/CHANGES b/CHANGES
index bea5db446046a2d1c436213b31ee47312b6b9512..753b49c37d3302cdd2cf879dea6cebf6ae8878a9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -159,6 +159,11 @@ Changes with Apache 2.1.0-dev
 
 Changes with Apache 2.0.46
 
+  *) If a Date response header was already set in the headers array,
+     this value was ignored in favour of the current time. This meant
+     that Date headers on proxied requests where rewritten when they
+     should not have been. PR: 14376 [Graham Leggett]
+
   *) Add code to buildconf that produces an httpd.spec file from
      httpd.spec.in, using build/get-version.sh from APR.
      [Graham Leggett]
index b692e21572e0604a18c7c7c5717c113cec337083..eac8daae11accb22a8df519a845308a82d32733b 100644 (file)
@@ -1251,7 +1251,7 @@ static void basic_http_header_check(request_rec *r,
 static void basic_http_header(request_rec *r, apr_bucket_brigade *bb,
                               const char *protocol)
 {
-    char *date;
+    const char *date;
     const char *server;
     header_struct h;
     struct iovec vec[4];
@@ -1283,12 +1283,19 @@ static void basic_http_header(request_rec *r, apr_bucket_brigade *bb,
     apr_brigade_writev(bb, NULL, NULL, vec, 4);
 #endif
 
-    date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
-    ap_recent_rfc822_date(date, r->request_time);
+    /* keep a previously set date header (possibly from proxy), otherwise
+     * generate a new date header */
+    if ((date = apr_table_get(r->headers_out, "Date")) != NULL) {
+        form_header_field(&h, "Date", date);
+    }
+    else {
+        char *now = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
+        ap_recent_rfc822_date(now, r->request_time);
 
-    h.pool = r->pool;
-    h.bb = bb;
-    form_header_field(&h, "Date", date);
+        h.pool = r->pool;
+        h.bb = bb;
+        form_header_field(&h, "Date", now);
+    }
 
     /* keep a previously set server header (possibly from proxy), otherwise
      * generate a new server header */
@@ -1300,7 +1307,7 @@ static void basic_http_header(request_rec *r, apr_bucket_brigade *bb,
     }
 
     /* unset so we don't send them again */
-    apr_table_unset(r->headers_out, "Date");        /* Avoid bogosity */
+    apr_table_unset(r->headers_out, "Date");
     apr_table_unset(r->headers_out, "Server");
 }