From: Jim Jagielski Date: Wed, 18 Aug 2010 14:30:50 +0000 (+0000) Subject: Pull out "does request have a body" logic to a central X-Git-Tag: 2.3.7~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6c87a875041744774e7cd2790b9c344806bb4ec;p=thirdparty%2Fapache%2Fhttpd.git Pull out "does request have a body" logic to a central canon function and use that for the 100-Continue OK check. Should likely also start using this in the various other places we do this "have body" check thruout the codebase... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@986699 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index aa7a9923dad..b97547f1688 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -243,6 +243,7 @@ * 20100723.0 (2.3.7-dev) Remove ct_output_filters from core rec * 20100723.1 (2.3.7-dev) Added ap_proxy_hashfunc() and hash elements to * proxy worker structs + * 20100723.2 (2.3.7-dev) Add ap_request_has_body() */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -250,7 +251,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20100723 #endif -#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/httpd.h b/include/httpd.h index c74a38e98c1..0447866cf37 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1806,6 +1806,14 @@ AP_DECLARE(apr_status_t) ap_timeout_parameter_parse( apr_interval_time_t *timeout, const char *default_time_unit); +/** + * Determine if a request has a request body or not. + * + * @param r the request_rec of the request + * @return truth value + */ +AP_DECLARE(int) ap_request_has_body(request_rec *r); + /* Misc system hackery */ /** * Given the name of an object in the file system determine if it is a directory diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index a8752041c99..518bf96e59e 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -696,7 +696,7 @@ int ap_proxy_http_request(apr_pool_t *p, request_rec *r, proxy_dir_conf *dconf; conn_rec *origin = p_conn->connection; int do_100_continue; - + dconf = ap_get_module_config(r->per_dir_config, &proxy_module); header_brigade = apr_brigade_create(p, origin->bucket_alloc); @@ -709,10 +709,7 @@ int ap_proxy_http_request(apr_pool_t *p, request_rec *r, * We also make sure we won't be talking HTTP/1.0 as well. */ do_100_continue = (worker->ping_timeout_set - && !r->header_only - && (r->kept_body - || apr_table_get(r->headers_in, "Content-Length") - || apr_table_get(r->headers_in, "Transfer-Encoding")) + && ap_request_has_body(r) && (PROXYREQ_REVERSE == r->proxyreq) && !(apr_table_get(r->subprocess_env, "force-proxy-request-1.0"))); @@ -1403,10 +1400,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, int do_100_continue; do_100_continue = (worker->ping_timeout_set - && !r->header_only - && (r->kept_body - || apr_table_get(r->headers_in, "Content-Length") - || apr_table_get(r->headers_in, "Transfer-Encoding")) + && ap_request_has_body(r) && (PROXYREQ_REVERSE == r->proxyreq) && !(apr_table_get(r->subprocess_env, "force-proxy-request-1.0"))); diff --git a/server/util.c b/server/util.c index 450fb54b5c0..844185802b8 100644 --- a/server/util.c +++ b/server/util.c @@ -2221,3 +2221,27 @@ AP_DECLARE(apr_status_t) ap_timeout_parameter_parse( return APR_SUCCESS; } +/** + * Determine if a request has a request body or not. + * + * @param r the request_rec of the request + * @return truth value + */ +AP_DECLARE(int) ap_request_has_body(request_rec *r) +{ + apr_off_t cl; + char *estr; + const char *cls; + int has_body; + + has_body = (!r->header_only + && (r->kept_body + || apr_table_get(r->headers_in, "Transfer-Encoding") + || ( (cls = apr_table_get(r->headers_in, "Content-Length")) + && (apr_strtoff(&cl, cls, &estr, 10) == APR_SUCCESS) + && (!*estr) + && (cl > 0) ) + ) + ); + return has_body; +}