From 335f9ca193a50899c801ba5742ad3d85f3f0dee6 Mon Sep 17 00:00:00 2001 From: Nick Kew Date: Sun, 7 Oct 2007 13:43:26 +0000 Subject: [PATCH] mod_proxy_http: Correctly forward unexpected interim (HTTP 1xx) responses. PR 16518 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@582631 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ docs/manual/mod/mod_proxy_http.xml | 11 +++++++++++ modules/proxy/mod_proxy_http.c | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/CHANGES b/CHANGES index 5aa1d332a6..e2c92e6788 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ Changes with Apache 2.3.0 [ When backported to 2.2.x, remove entry from this file ] + *) mod_proxy_http: Correctly forward unexpected interim (HTTP 1xx) + responses from the backend according to RFC2616. But make it + configurable in case something breaks on it. + PR 16518 [Nick Kew] + *) mod_ext_filter: Prevent a hang on Windows when the filter input data is pipelined. PR 29901 [Eric Covener] diff --git a/docs/manual/mod/mod_proxy_http.xml b/docs/manual/mod/mod_proxy_http.xml index 4cd42f2abf..13046a324c 100644 --- a/docs/manual/mod/mod_proxy_http.xml +++ b/docs/manual/mod/mod_proxy_http.xml @@ -90,6 +90,17 @@ request bodies to be sent to the backend using chunked transfer encoding. This allows the request to be efficiently streamed, but requires that the backend server supports HTTP/1.1. +
proxy-interim-response
+
This variable takes values RFC or + Suppress. Earlier httpd versions would suppress + HTTP interim (1xx) responses sent from the backend. This is + technically a violation of the HTTP protocol. In practice, + if a backend sends an interim response, it may itself be + extending the protocol in a manner we know nothing about, + or just broken. So this is now configurable: set + proxy-interim-response RFC to be fully protocol + compliant, or proxy-interim-response Suppress + to suppress interim responses.
diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index a4959a2ff3..f2a6827f5c 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -1494,9 +1494,33 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, interim_response = ap_is_HTTP_INFO(r->status); if (interim_response) { + /* RFC2616 tells us to forward this. + * + * OTOH, an interim response here may mean the backend + * is playing sillybuggers. The Client didn't ask for + * it within the defined HTTP/1.1 mechanisms, and if + * it's an extension, it may also be unsupported by us. + * + * There's also the possibility that changing existing + * behaviour here might break something. + * + * So let's make it configurable. + */ + const char *policy = apr_table_get(r->subprocess_env, + "proxy-interim-response"); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, "proxy: HTTP: received interim %d response", r->status); + if (!policy || !strcasecmp(policy, "RFC")) { + ap_send_interim_response(r); + } + /* FIXME: refine this to be able to specify per-response-status + * policies and maybe also add option to bail out with 502 + */ + else if (strcasecmp(policy, "Suppress")) { + ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, + "undefined proxy interim response policy"); + } } /* Moved the fixups of Date headers and those affected by * ProxyPassReverse/etc from here to ap_proxy_read_headers -- 2.40.0