From a5e672195bec280019eaf270042065e01b5ed381 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Tue, 2 Aug 2016 16:27:26 +0000 Subject: [PATCH] mod_proxy_http: don't pretend we are sending a body before ProxyErrorOverride takes place, the response it to be handled by ErrorDocument is this case. Also it useless to take care of pre-read data since the body is discarded in this case. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754974 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy_http.c | 54 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index edcccdfb5a..2debfccfa1 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -1552,7 +1552,7 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, } else { /* an http/0.9 response */ backasswards = 1; - r->status = 200; + r->status = proxy_status = 200; r->status_line = "200 OK"; backend->close = 1; } @@ -1601,6 +1601,7 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, "undefined proxy interim response policy"); } } + /* Moved the fixups of Date headers and those affected by * ProxyPassReverse/etc from here to ap_proxy_read_headers */ @@ -1617,31 +1618,6 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, } } - r->sent_bodyct = 1; - /* - * Is it an HTTP/0.9 response or did we maybe preread the 1st line of - * the response? If so, load the extra data. These are 2 mutually - * exclusive possibilities, that just happen to require very - * similar behavior. - */ - if (backasswards || pread_len) { - apr_ssize_t cntr = (apr_ssize_t)pread_len; - if (backasswards) { - /*@@@FIXME: - * At this point in response processing of a 0.9 response, - * we don't know yet whether data is binary or not. - * mod_charset_lite will get control later on, so it cannot - * decide on the conversion of this buffer full of data. - * However, chances are that we are not really talking to an - * HTTP/0.9 server, but to some different protocol, therefore - * the best guess IMHO is to always treat the buffer as "text/x": - */ - ap_xlate_proto_to_ascii(buffer, len); - cntr = (apr_ssize_t)len; - } - 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) && dconf->error_override) { /* clear r->status for override error, otherwise ErrorDocument @@ -1676,6 +1652,32 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, return proxy_status; } + r->sent_bodyct = 1; + /* + * Is it an HTTP/0.9 response or did we maybe preread the 1st line of + * the response? If so, load the extra data. These are 2 mutually + * exclusive possibilities, that just happen to require very + * similar behavior. + */ + if (backasswards || pread_len) { + apr_ssize_t cntr = (apr_ssize_t)pread_len; + if (backasswards) { + /*@@@FIXME: + * At this point in response processing of a 0.9 response, + * we don't know yet whether data is binary or not. + * mod_charset_lite will get control later on, so it cannot + * decide on the conversion of this buffer full of data. + * However, chances are that we are not really talking to an + * HTTP/0.9 server, but to some different protocol, therefore + * the best guess IMHO is to always treat the buffer as "text/x": + */ + ap_xlate_proto_to_ascii(buffer, len); + cntr = (apr_ssize_t)len; + } + e = apr_bucket_heap_create(buffer, cntr, NULL, c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(bb, e); + } + /* send body - but only if a body is expected */ if ((!r->header_only) && /* not HEAD request */ !interim_response && /* not any 1xx response */ -- 2.40.0