Conti, Chris
2003-05-02 20:51:42 UTC
We ran into a situation where a command-response protocol was being tunneled
through HTTP (2 sockets 1 is an HTTP GET, the other an HTTP POST) that
failed when passed through an Apache reverse proxy. The HTTP requests are
marked with keep-alive, but when the data passing from the server <
AP_MIN_BYTES_TO_WRITE (8000 decimal) then the bucket brigade buffers the
data instead of passing it on.
The guts of the patch are basically appending a flush bucket after every
read(unless there is already an EOS) if the ProxyWriteThrough directive is
set to On
I'm pretty new to Apache, and while this seems like the appropriate fix to
the problem, I have to ask if there might be a better way?
---------------------------------------------------------
Chris Conti
***@mindspring.com
***@xcellenet.com
diff -u \ApacheSrc\httpd-2.0.45\modules\proxy\proxy_http.c
\ApacheSrc-orig\httpd-2.0.45\modules\proxy\proxy_http.c
--- \ApacheSrc\httpd-2.0.45\modules\proxy\proxy_http.c 2003-05-02
16:22:53.000000000 -0400
+++ \ApacheSrc-orig\httpd-2.0.45\modules\proxy\proxy_http.c 2003-02-03
10:31:50.000000000 -0500
@@ -956,18 +956,6 @@
/* signal that we must leave */
finish = TRUE;
}
-
- /* do we need to always send the data? */
- if (conf->write_through && !finish){
- apr_off_t readbytes;
- apr_brigade_length(bb, 0, &readbytes);
-
-
- if(0 != readbytes){
- apr_bucket *e =
apr_bucket_flush_create(c->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(bb, e);
- }
- }
/* try send what we read */
if (ap_pass_brigade(r->output_filters, bb) !=
APR_SUCCESS)
{
diff -u \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.h
\ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.h
--- \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.h 2003-04-29
09:20:12.000000000 -0400
+++ \ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.h 2003-02-03
10:31:50.000000000 -0500
@@ -201,8 +201,6 @@
bad_body
} badopt; /* how to deal with bad headers */
char badopt_set;
- int write_through;
- char write_through_set;
} proxy_server_conf;
diff -u \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.c
\ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.c
--- \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.c 2003-04-29
09:20:12.000000000 -0400
+++ \ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.c 2003-02-22
11:38:14.000000000 -0500
@@ -503,8 +503,6 @@
ps->timeout_set = 0;
ps->badopt = bad_error;
ps->badopt_set = 0;
- ps->write_through = 0;
- ps->write_through_set = 0;
return ps;
}
@@ -532,7 +530,6 @@
ps->preserve_host = (overrides->preserve_host_set == 0) ?
base->preserve_host : overrides->preserve_host;
ps->timeout= (overrides->timeout_set == 0) ? base->timeout :
overrides->timeout;
ps->badopt = (overrides->badopt_set == 0) ? base->badopt :
overrides->badopt;
- ps->write_through = (overrides->write_through_set == 0) ?
base->write_through : overrides->write_through;
return ps;
}
@@ -816,16 +813,6 @@
psf->req_set = 1;
return NULL;
}
-static const char*
- set_proxy_writethrough(cmd_parms *parms, void *dummy, int flag)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
-
- psf->write_through = flag;
- psf->write_through_set = 1;
- return NULL;
-}
static const char *
set_proxy_error_override(cmd_parms *parms, void *dummy, int flag)
{
@@ -1079,8 +1066,6 @@
"This overrides the server timeout"),
AP_INIT_TAKE1("ProxyBadHeader", set_bad_opt, NULL, RSRC_CONF,
"How to handle bad header line in response: IsError | Ignore |
StartBody"),
- AP_INIT_FLAG("ProxyWriteThrough", set_proxy_writethrough, NULL,
RSRC_CONF,
- "on if the data should be not be buffered"),
{NULL}
};
through HTTP (2 sockets 1 is an HTTP GET, the other an HTTP POST) that
failed when passed through an Apache reverse proxy. The HTTP requests are
marked with keep-alive, but when the data passing from the server <
AP_MIN_BYTES_TO_WRITE (8000 decimal) then the bucket brigade buffers the
data instead of passing it on.
The guts of the patch are basically appending a flush bucket after every
read(unless there is already an EOS) if the ProxyWriteThrough directive is
set to On
I'm pretty new to Apache, and while this seems like the appropriate fix to
the problem, I have to ask if there might be a better way?
---------------------------------------------------------
Chris Conti
***@mindspring.com
***@xcellenet.com
diff -u \ApacheSrc\httpd-2.0.45\modules\proxy\proxy_http.c
\ApacheSrc-orig\httpd-2.0.45\modules\proxy\proxy_http.c
--- \ApacheSrc\httpd-2.0.45\modules\proxy\proxy_http.c 2003-05-02
16:22:53.000000000 -0400
+++ \ApacheSrc-orig\httpd-2.0.45\modules\proxy\proxy_http.c 2003-02-03
10:31:50.000000000 -0500
@@ -956,18 +956,6 @@
/* signal that we must leave */
finish = TRUE;
}
-
- /* do we need to always send the data? */
- if (conf->write_through && !finish){
- apr_off_t readbytes;
- apr_brigade_length(bb, 0, &readbytes);
-
-
- if(0 != readbytes){
- apr_bucket *e =
apr_bucket_flush_create(c->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(bb, e);
- }
- }
/* try send what we read */
if (ap_pass_brigade(r->output_filters, bb) !=
APR_SUCCESS)
{
diff -u \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.h
\ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.h
--- \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.h 2003-04-29
09:20:12.000000000 -0400
+++ \ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.h 2003-02-03
10:31:50.000000000 -0500
@@ -201,8 +201,6 @@
bad_body
} badopt; /* how to deal with bad headers */
char badopt_set;
- int write_through;
- char write_through_set;
} proxy_server_conf;
diff -u \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.c
\ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.c
--- \ApacheSrc\httpd-2.0.45\modules\proxy\mod_proxy.c 2003-04-29
09:20:12.000000000 -0400
+++ \ApacheSrc-orig\httpd-2.0.45\modules\proxy\mod_proxy.c 2003-02-22
11:38:14.000000000 -0500
@@ -503,8 +503,6 @@
ps->timeout_set = 0;
ps->badopt = bad_error;
ps->badopt_set = 0;
- ps->write_through = 0;
- ps->write_through_set = 0;
return ps;
}
@@ -532,7 +530,6 @@
ps->preserve_host = (overrides->preserve_host_set == 0) ?
base->preserve_host : overrides->preserve_host;
ps->timeout= (overrides->timeout_set == 0) ? base->timeout :
overrides->timeout;
ps->badopt = (overrides->badopt_set == 0) ? base->badopt :
overrides->badopt;
- ps->write_through = (overrides->write_through_set == 0) ?
base->write_through : overrides->write_through;
return ps;
}
@@ -816,16 +813,6 @@
psf->req_set = 1;
return NULL;
}
-static const char*
- set_proxy_writethrough(cmd_parms *parms, void *dummy, int flag)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
-
- psf->write_through = flag;
- psf->write_through_set = 1;
- return NULL;
-}
static const char *
set_proxy_error_override(cmd_parms *parms, void *dummy, int flag)
{
@@ -1079,8 +1066,6 @@
"This overrides the server timeout"),
AP_INIT_TAKE1("ProxyBadHeader", set_bad_opt, NULL, RSRC_CONF,
"How to handle bad header line in response: IsError | Ignore |
StartBody"),
- AP_INIT_FLAG("ProxyWriteThrough", set_proxy_writethrough, NULL,
RSRC_CONF,
- "on if the data should be not be buffered"),
{NULL}
};