From e3befc624eef5c33bf5eb6f1858ae595502e9349 Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Tue, 15 Apr 2003 17:39:43 +0000 Subject: [PATCH] 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 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 | 5 +++++ modules/http/http_protocol.c | 21 ++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index bea5db4460..753b49c37d 100644 --- 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] diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index b692e21572..eac8daae11 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -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"); } -- 2.40.0