From: Justin Erenkrantz Date: Thu, 30 May 2002 07:04:45 +0000 (+0000) Subject: Add a PROXYREQ_RESPONSE value for request_rec->proxyreq because it is X-Git-Tag: 2.0.37~174 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5607afff2be5ec3f6a23b671f9aa9a6c49c158ea;p=apache Add a PROXYREQ_RESPONSE value for request_rec->proxyreq because it is possible that there can be different behavior at the protocol level if request_rec isn't really a request but a response. This stems from the fact that request bodies must be indicated by Content-Length or Transfer-Encoding, but response bodies do not. The recent change to ap_http_filter to return EOS if there isn't a body broke proxy. Therefore, there must be some way for the proxy to indicate that this is a response. Accordingly, ap_http_filter can allow the BODY_NONE iff this is a response. Since r->proxyreq is set to PROXYREQ_PROXY even for the original request from the client, that value isn't sufficient. Hence, the introduction of PROXYREQ_RESPONSE. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95390 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/httpd.h b/include/httpd.h index bead0e2043..78cdb4121a 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -729,7 +729,8 @@ struct request_rec { /** HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers) */ int assbackwards; /** A proxy request (calculated during post_read_request/translate_name) - * possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE + * possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE, + * PROXYREQ_RESPONSE */ int proxyreq; /** HEAD request, as opposed to GET */ @@ -945,6 +946,7 @@ struct request_rec { #define PROXYREQ_NONE 0 /**< No proxy */ #define PROXYREQ_PROXY 1 /**< Standard proxy */ #define PROXYREQ_REVERSE 2 /**< Reverse proxy */ +#define PROXYREQ_RESPONSE 3 /**< Origin response */ /* @} */ diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 3939594eef..1fc2a666e9 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -829,8 +829,11 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, * RFC 2616 Section 4.4 note 5 states that connection-close * is invalid for a request entity - request bodies must be * denoted by C-L or T-E: chunked. + * + * Note that since the proxy uses this filter to handle the + * proxied *response*, proxy responses MUST be exempt. */ - if (ctx->state == BODY_NONE) { + if (ctx->state == BODY_NONE && f->r->proxyreq != PROXYREQ_RESPONSE) { e = apr_bucket_eos_create(f->r->connection->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); return APR_SUCCESS; diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index 8b08f7a6fa..589d44d6bc 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -663,6 +663,10 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, */ rp = ap_proxy_make_fake_req(origin, r); + /* In case anyone needs to know, this is a fake request that is really a + * response. + */ + rp->proxyreq = PROXYREQ_RESPONSE; while (received_continue) { apr_brigade_cleanup(bb);