1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

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
This commit is contained in:
Yann Ylavic
2020-07-02 00:14:26 +00:00
parent 29bcc0eaa3
commit b5faaa48c3
3 changed files with 219 additions and 53 deletions

View File

@@ -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;
}
@@ -2479,6 +2493,33 @@ static const char *
return NULL;
}
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)
{
@@ -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}
};