]> granicus.if.org Git - apache/commitdiff
mod_proxy: follow up to r1836588: configurable Proxy100Continue.
authorYann Ylavic <ylavic@apache.org>
Fri, 22 Mar 2019 09:53:29 +0000 (09:53 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 22 Mar 2019 09:53:29 +0000 (09:53 +0000)
Add Proxy100Continue directive to allow for 100-continue forwarding opt-out.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1856036 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/mod/mod_proxy.xml
include/ap_mmn.h
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_http.c

index 64c27c9a2a7bb1c083c5b7d50f96ad02e0de71c4..622a7c85f2336ff719a999cbfe4f392c9310e01a 100644 (file)
@@ -2128,6 +2128,29 @@ header for proxied requests</description>
 </usage>
 </directivesynopsis>
 
+<directivesynopsis>
+<name>Proxy100Continue</name>
+<description>Forward 100-continue expectation to the origin server</description>
+<syntax>Proxy100Continue Off|On</syntax>
+<default>Proxy100Continue On</default>
+<contextlist><context>server config</context>
+<context>virtual host</context>
+<context>directory</context>
+</contextlist>
+<compatibility>Available in version 2.4.39 and later</compatibility>
+
+<usage>
+    <p>This directive determines whether the proxy should forward 100-continue
+    <em>Expect:</em>ation to the origin server and thus let it decide when/if
+    the HTTP request body should be read, or when <code>Off</code> the proxy
+    should generate <em>100 Continue</em> intermediate response by itself before
+    forwarding the request body.</p>
+    <note><title>Effectiveness</title>
+     <p>This option is of use only for HTTP proxying, as handled by <module>mod_proxy_http</module>.</p>
+    </note>
+</usage>
+</directivesynopsis>
+
 <directivesynopsis>
 <name>ProxySourceAddress</name>
 <description>Set local IP address for outgoing proxy connections</description>
index 5a479c075e6263c22f2886c6c4d3168e04b339b9..8f9cab17af7cb6dc66552e2bbe28242522b17452 100644 (file)
  * 20191203.1 (2.5.1-dev)  Axe bucket number from struct process_score
  * 20191203.2 (2.5.1-dev)  Add ap_no2slash_ex() and merge_slashes to 
  *                         core_server_conf.
+ * 20191203.3 (2.5.1-dev)  Add forward_100_continue{,_set} to proxy_dir_conf
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20191203
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 2                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 3                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index d754f7b09ee1cb088a70b93771eb9c803bd328b6..251afbf3a229a74f857653e2d9bcee8e094b9ed6 100644 (file)
@@ -1579,6 +1579,8 @@ static void *create_proxy_dir_config(apr_pool_t *p, char *dummy)
     new->error_override_set = 0;
     new->add_forwarded_headers = 1;
     new->add_forwarded_headers_set = 0;
+    new->forward_100_continue = 1;
+    new->forward_100_continue_set = 0;
 
     return (void *) new;
 }
@@ -1615,6 +1617,11 @@ static void *merge_proxy_dir_config(apr_pool_t *p, void *basev, void *addv)
         : add->add_forwarded_headers;
     new->add_forwarded_headers_set = add->add_forwarded_headers_set
         || base->add_forwarded_headers_set;
+    new->forward_100_continue =
+        (add->forward_100_continue_set == 0) ? base->forward_100_continue
+                                             : add->forward_100_continue;
+    new->forward_100_continue_set = add->forward_100_continue_set
+                                    || base->forward_100_continue_set;
     
     return new;
 }
@@ -2130,6 +2137,14 @@ static const char *
     conf->preserve_host_set = 1;
     return NULL;
 }
+static const char *
+   forward_100_continue(cmd_parms *parms, void *dconf, int flag)
+{
+   proxy_dir_conf *conf = dconf;
+   conf->forward_100_continue = flag;
+   conf->forward_100_continue_set = 1;
+   return NULL;
+}
 
 static const char *
     set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
@@ -2717,6 +2732,9 @@ static const command_rec proxy_cmds[] =
      "Configure local source IP used for request forward"),
     AP_INIT_FLAG("ProxyAddHeaders", add_proxy_http_headers, NULL, RSRC_CONF|ACCESS_CONF,
      "on if X-Forwarded-* headers should be added or completed"),
+    AP_INIT_FLAG("Proxy100Continue", forward_100_continue, NULL, RSRC_CONF|ACCESS_CONF,
+     "on if 100-Continue should be forwarded to the origin server, off if the "
+     "proxy should handle it by itself"),
     {NULL}
 };
 
index 152a79103e6bd5b3393c5608a69ff6ad057bb9ea..e94f64c533e55a21d1017fa82cd4560f5fde878e 100644 (file)
@@ -240,6 +240,8 @@ typedef struct {
     /** Named back references */
     apr_array_header_t *refs;
 
+    unsigned int forward_100_continue:1;
+    unsigned int forward_100_continue_set:1;
 } proxy_dir_conf;
 
 /* if we interpolate env vars per-request, we'll need a per-request
index 8bd5e2d5e2da7f61e9ec5a07492be8284d5d0246..4dfdfd1672f9678ab979d4c74e0a97a16b21f781 100644 (file)
@@ -1947,6 +1947,7 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker,
     proxy_conn_rec *backend = NULL;
     int is_ssl = 0;
     conn_rec *c = r->connection;
+    proxy_dir_conf *dconf;
     int retry = 0;
     char *locurl = url;
     int toclose = 0;
@@ -2007,8 +2008,11 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker,
     req->bucket_alloc = c->bucket_alloc;
     req->rb_method = RB_INIT;
 
+    dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
+
     /* Should we handle end-to-end or ping 100-continue? */
-    if (r->expecting_100 || PROXY_DO_100_CONTINUE(worker, r)) {
+    if ((r->expecting_100 && dconf->forward_100_continue)
+            || PROXY_DO_100_CONTINUE(worker, r)) {
         /* We need to reset r->expecting_100 or prefetching will cause
          * ap_http_filter() to send "100 Continue" response by itself. So
          * we'll use req->expecting_100 in mod_proxy_http to determine whether