]> granicus.if.org Git - apache/commitdiff
Pull out "does request have a body" logic to a central
authorJim Jagielski <jim@apache.org>
Wed, 18 Aug 2010 14:30:50 +0000 (14:30 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 18 Aug 2010 14:30:50 +0000 (14:30 +0000)
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

include/ap_mmn.h
include/httpd.h
modules/proxy/mod_proxy_http.c
server/util.c

index aa7a9923dad794f2ab795e6f096bbd1548129050..b97547f16889466cce8c3c132c8e4f01628d583d 100644 (file)
  * 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" */
 #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
index c74a38e98c17ea22806b70d4fd44a972440ad0b1..0447866cf378b4776c5ed159c1644b40eeeeef10 100644 (file)
@@ -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
index a8752041c99549a647f589205eda16356446f6d4..518bf96e59e3b5c0a625fe10cd6e1ceabd65f5e4 100644 (file)
@@ -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")));
     
index 450fb54b5c0a557c9d286899584b622bcc4c4312..844185802b85d5d704bc43c78c2339266ebd7725 100644 (file)
@@ -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;
+}