From d8501971c7241b39afa2af5c18ae639ef976b04e Mon Sep 17 00:00:00 2001 From: Nick Kew Date: Tue, 2 Oct 2007 00:39:43 +0000 Subject: [PATCH] Default to NOT setting Max-Forwards in violation of RFC2616 Leave old behaviour as a configuration option (ProxyMaxForwards) PR 16137 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@581117 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ modules/proxy/mod_proxy.c | 9 ++++----- modules/proxy/mod_proxy.h | 5 ++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 29e4fa47cf..a1deb00fd3 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: Don't by default violate RFC2616 by setting + Max-Forwards when the client didn't send it to us. + Leave that as a configuration option. + PR 16137 [Nick Kew] + *) mod_proxy_http: Remove Warning headers with wrong date PR 16138 [Nick Kew] diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index d5265334bf..31b5d8540d 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -784,8 +784,10 @@ static int proxy_handler(request_rec *r) /* set configured max-forwards */ maxfwd = conf->maxfwd; } - apr_table_set(r->headers_in, "Max-Forwards", - apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0)); + if (maxfwd >= 0) { + apr_table_set(r->headers_in, "Max-Forwards", + apr_psprintf(r->pool, "%ld", maxfwd)); + } if (r->method_number == M_TRACE) { core_server_config *coreconf = (core_server_config *) @@ -1535,9 +1537,6 @@ static const char * proxy_server_conf *psf = ap_get_module_config(parms->server->module_config, &proxy_module); long s = atol(arg); - if (s < 0) { - return "ProxyMaxForwards must be greater or equal to zero.."; - } psf->maxfwd = s; psf->maxfwd_set = 1; diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 32e0313155..de73723a1b 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -94,7 +94,10 @@ enum enctype { #endif /*APR_CHARSET_EBCDIC*/ /* default Max-Forwards header setting */ -#define DEFAULT_MAX_FORWARDS 10 +/* Set this to -1, which complies with RFC2616 by not setting + * max-forwards if the client didn't send it to us. + */ +#define DEFAULT_MAX_FORWARDS -1 /* static information about a remote proxy */ struct proxy_remote { -- 2.40.0