diff options
author | Yann Ylavic <ylavic@apache.org> | 2020-07-02 00:14:26 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2020-07-02 00:14:26 +0000 |
commit | b5faaa48c3665cc0f6487109ad9253cc3ae1ed46 (patch) | |
tree | 5cbe6a8c4841cf0f4b9bbe76e84eea5651bb7568 /modules/proxy/mod_proxy.c | |
parent | 29bcc0eaa3ffd4ca419d831d8c5ba57f58229bf2 (diff) | |
download | httpd-b5faaa48c3665cc0f6487109ad9253cc3ae1ed46.tar.gz |
mod_proxy_http: handle async tunneling of Upgrade(d) protocols.
When supported by the MPM (i.e. "event"), provide async callbacks and let
them be scheduled by ap_mpm_register_poll_callback_timeout(), while the
handler returns SUSPENDED.
The new ProxyAsyncDelay directive (if positive) enables async handling,
while ProxyAsyncIdleTimeout determines the timeout applied on both ends
while tunneling.
Github: closes #126
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879419 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/proxy/mod_proxy.c')
-rw-r--r-- | modules/proxy/mod_proxy.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index d730a6d047..33060b08f2 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -1842,6 +1842,7 @@ static void *create_proxy_dir_config(apr_pool_t *p, char *dummy) new->add_forwarded_headers_set = 0; new->forward_100_continue = 1; new->forward_100_continue_set = 0; + new->async_delay = -1; return (void *) new; } @@ -1889,17 +1890,30 @@ static void *merge_proxy_dir_config(apr_pool_t *p, void *basev, void *addv) new->error_override_set = add->error_override_set || base->error_override_set; new->alias = (add->alias_set == 0) ? base->alias : add->alias; new->alias_set = add->alias_set || base->alias_set; + new->add_forwarded_headers = (add->add_forwarded_headers_set == 0) ? base->add_forwarded_headers : 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; + new->async_delay = + (add->async_delay_set == 0) ? base->async_delay + : add->async_delay; + new->async_delay_set = add->async_delay_set + || base->async_delay_set; + new->async_idle_timeout = + (add->async_idle_timeout_set == 0) ? base->async_idle_timeout + : add->async_idle_timeout; + new->async_idle_timeout_set = add->async_idle_timeout_set + || base->async_idle_timeout_set; + return new; } @@ -2480,6 +2494,33 @@ static const char * } static const char * + set_proxy_async_delay(cmd_parms *parms, void *dconf, const char *arg) +{ + proxy_dir_conf *conf = dconf; + if (strcmp(arg, "-1") == 0) { + conf->async_delay = -1; + } + else if (ap_timeout_parameter_parse(arg, &conf->async_delay, "s") + || conf->async_delay < 0) { + return "ProxyAsyncDelay has wrong format"; + } + conf->async_delay_set = 1; + return NULL; +} + +static const char * + set_proxy_async_idle(cmd_parms *parms, void *dconf, const char *arg) +{ + proxy_dir_conf *conf = dconf; + if (ap_timeout_parameter_parse(arg, &conf->async_idle_timeout, "s") + || conf->async_idle_timeout < 0) { + return "ProxyAsyncIdleTimeout has wrong format"; + } + conf->async_idle_timeout_set = 1; + return NULL; +} + +static const char * set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg) { proxy_server_conf *psf = @@ -3068,6 +3109,10 @@ static const command_rec proxy_cmds[] = 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"), + AP_INIT_TAKE1("ProxyAsyncDelay", set_proxy_async_delay, NULL, RSRC_CONF|ACCESS_CONF, + "Amount of time to poll before going asynchronous"), + AP_INIT_TAKE1("ProxyAsyncIdleTimeout", set_proxy_async_idle, NULL, RSRC_CONF|ACCESS_CONF, + "Timeout for asynchronous inactivity, ProxyTimeout by default"), {NULL} }; |