From f28e2bdea4f6e806eaa777b9e59f3344397418c5 Mon Sep 17 00:00:00 2001 From: Nick Kew Date: Sat, 20 Feb 2010 01:54:15 +0000 Subject: [PATCH] mod_proxy_http: get the headers right in a HEAD request with ProxyErrorOverride.PR 41646 Analysis by Stuart Children; patch by niq git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@912063 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 6 ++++++ modules/proxy/mod_proxy_http.c | 39 ++++++++++++++-------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index d592d3fdf6..047a2cb30c 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,12 @@ Changes with Apache 2.3.7 + *) Proxy: get the headers right in a HEAD request with + ProxyErrorOverride, by checking for an overridden error + before not after going into a catch-all code path. + PR 41646. + Patch by Nick Kew, based on detailed analysis by Stuart Children. + *) support/rotatelogs: Support the simplest log rotation case, log truncation. Useful when the log is being processed in real time using a command like tail. [Graham Leggett] diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index 0bedea01d3..0225b7a275 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -1704,6 +1704,21 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, e = apr_bucket_heap_create(buffer, cntr, NULL, c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); } + /* PR 41646: get HEAD right with ProxyErrorOverride */ + if (ap_is_HTTP_ERROR(r->status) && conf->error_override) { + /* clear r->status for override error, otherwise ErrorDocument + * thinks that this is a recursive error, and doesn't find the + * custom error page + */ + r->status = HTTP_OK; + /* Discard body, if one is expected */ + if (!r->header_only && /* not HEAD request */ + (proxy_status != HTTP_NO_CONTENT) && /* not 204 */ + (proxy_status != HTTP_NOT_MODIFIED)) { /* not 304 */ + ap_discard_request_body(rp); + } + return proxy_status; + } /* send body - but only if a body is expected */ if ((!r->header_only) && /* not HEAD request */ @@ -1865,29 +1880,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, return DONE; } - if (conf->error_override) { - /* the code above this checks for 'OK' which is what the hook expects */ - if (!ap_is_HTTP_ERROR(proxy_status)) { - return OK; - } - else { - /* clear r->status for override error, otherwise ErrorDocument - * thinks that this is a recursive error, and doesn't find the - * custom error page - */ - r->status = HTTP_OK; - /* Discard body, if one is expected */ - if (!r->header_only && /* not HEAD request */ - (proxy_status != HTTP_NO_CONTENT) && /* not 204 */ - (proxy_status != HTTP_NOT_MODIFIED)) { /* not 304 */ - ap_discard_request_body(rp); - } - return proxy_status; - } - } - else { - return OK; - } + return OK; } static -- 2.40.0