Still hoping for some feedback. Note that this proposal affects anyone
who tries to implement a proxy feed from CGI, modperl, tomcat, php,
or any other interesting mechanism, where the user can't manipulate
the r->proxyreq flag :)
Bill
>Date: Fri, 28 May 2004 13:02:14 -0500
>To: [EMAIL PROTECTED]
>From: "William A. Rowe, Jr." <[EMAIL PROTECTED]>
>
>I'd worked with some interesting java and cgi code which implements
>proxy behavior, as opposed to using a compiled-in module such as
>mod_proxy. In order to properly pass on the Server: and Date: headers
>(which are owned by the origin server), this patch tests for the presence
>of a Via: header, indicating the response is proxied.
>
>If neither r->proxyreq nor a 'Via:' header exist, the server still overrides
>the Server: and Date: responses, per RFC.
>
>Comments appreciated.
>
>Bill
--- src/main/http_protocol.c 15 Apr 2004 15:51:51 -0000 1.335
+++ src/main/http_protocol.c 28 May 2004 18:00:10 -0000
@@ -1544,6 +1544,8 @@
API_EXPORT(void) ap_basic_http_header(request_rec *r)
{
char *protocol;
+ const char *datestr = NULL;
+ const char *server = NULL;
if (r->assbackwards)
return;
@@ -1569,20 +1571,29 @@
/* 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));
+ /* keep the set-by-proxy date header, otherwise
+ * generate a new server header */
+ if (r->proxyreq || ap_table_get(r->headers_out, "Via")) {
+ datestr = ap_table_get(r->headers_out, "Date");
+
+ if (datestr && (ap_parseHTTPdate(datestr) == BAD_DATE)) {
+ datestr = NULL;
+ }
+ }
+ if (!datestr || !*datestr) {
+ datestr = ap_gm_timestr_822(r->pool, r->request_time);
+ }
+ ap_send_header_field(r, "Date", datestr);
/* keep the set-by-proxy server header, otherwise
* generate a new server header */
- if (r->proxyreq) {
- const char *server = ap_table_get(r->headers_out, "Server");
- if (server) {
- ap_send_header_field(r, "Server", server);
- }
+ if (r->proxyreq || ap_table_get(r->headers_out, "Via")) {
+ server = ap_table_get(r->headers_out, "Server");
}
- else {
- ap_send_header_field(r, "Server", ap_get_server_version());
+ if (!server || !*server) {
+ server = ap_get_server_version();
}
+ ap_send_header_field(r, "Server", server);
/* unset so we don't send them again */
ap_table_unset(r->headers_out, "Date"); /* Avoid bogosity */