From 76a21a1c1ae8384f084d6852098babc0e2c9f5fc Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Thu, 21 Mar 2002 14:49:46 +0000 Subject: [PATCH] When a proxied site was being served, Apache was replacing the original site Server header with it's own, which is not allowed by RFC2616. Fixed. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@94085 13f79535-47bb-0310-9956-ffa450edef68 --- src/CHANGES | 4 ++++ src/main/http_protocol.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/CHANGES b/src/CHANGES index 0b3e233d2d4..1e3137c4487 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 1.3.24 + *) When a proxied site was being served, Apache was replacing + the original site Server header with it's own, which is not + allowed by RFC2616. Fixed. [Graham Leggett] + *) Change ap_construct_url() so that the r->hostname is used in the URL instead of the value of the ServerName directive. This stops Apache redirecting to a different website name to the diff --git a/src/main/http_protocol.c b/src/main/http_protocol.c index e1b32523ebb..7da84f785b3 100644 --- a/src/main/http_protocol.c +++ b/src/main/http_protocol.c @@ -1513,6 +1513,7 @@ API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r, API_EXPORT(void) ap_basic_http_header(request_rec *r) { char *protocol; + const char *server; if (r->assbackwards) return; @@ -1535,13 +1536,22 @@ API_EXPORT(void) ap_basic_http_header(request_rec *r) PUSH_EBCDIC_OUTPUTCONVERSION_STATE_r(r, 1); #endif /*CHARSET_EBCDIC*/ - /* Output the HTTP/1.x Status-Line and the Date and Server fields */ - + /* output the HTTP/1.x Status-Line */ ap_rvputs(r, protocol, " ", r->status_line, CRLF, NULL); + /* output the date header */ ap_send_header_field(r, "Date", ap_gm_timestr_822(r->pool, r->request_time)); - ap_send_header_field(r, "Server", ap_get_server_version()); + /* keep a previously set server header (possible from proxy), otherwise + * generate a new server header */ + if (server = ap_table_get(r->headers_out, "Server")) { + ap_send_header_field(r, "Server", server); + } + else { + ap_send_header_field(r, "Server", ap_get_server_version()); + } + + /* unset so we don't send them again */ ap_table_unset(r->headers_out, "Date"); /* Avoid bogosity */ ap_table_unset(r->headers_out, "Server"); #ifdef CHARSET_EBCDIC -- 2.47.2