summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2005-08-08 00:30:27 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2005-08-08 00:30:27 +0000
commite9715ebd1a518bfc33213b2dea4161bb0079ac9a (patch)
treebde340e15b2e573fa92272b08fb75091880741b8
parentbb9b79080e75caf4692da1c504017a776321edab (diff)
downloadhttpd-e9715ebd1a518bfc33213b2dea4161bb0079ac9a.tar.gz
Finish up the header brigades up-front; we simply know ahead of time if
they are necessary or not. This changes one behavior; the stream_chunked now always sends a transfer encoded body; even if it's nothing but an empty body. Also, Fix a bugglet in backporting the input_brigade argument; need the bucket_alloc already. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/proxy-reqbody-2.0.x@230716 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--modules/proxy/proxy_http.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c
index e51c843dbb..780606d1ee 100644
--- a/modules/proxy/proxy_http.c
+++ b/modules/proxy/proxy_http.c
@@ -466,6 +466,9 @@ static apr_status_t stream_reqbody_chunked(apr_pool_t *p,
apr_bucket_brigade *b;
apr_bucket *e;
+ add_te_chunked(p, bucket_alloc, header_brigade);
+ terminate_headers(bucket_alloc, header_brigade);
+
do {
char chunk_hdr[20]; /* must be here due to transient bucket. */
@@ -514,8 +517,6 @@ static apr_status_t stream_reqbody_chunked(apr_pool_t *p,
/* we never sent the header brigade, so go ahead and
* take care of that now
*/
- add_te_chunked(p, bucket_alloc, header_brigade);
- terminate_headers(bucket_alloc, header_brigade);
b = header_brigade;
APR_BRIGADE_CONCAT(b, input_brigade);
header_brigade = NULL;
@@ -532,9 +533,8 @@ static apr_status_t stream_reqbody_chunked(apr_pool_t *p,
if (header_brigade) {
/* we never sent the header brigade because there was no request body;
- * send it now without T-E
+ * send it now
*/
- terminate_headers(bucket_alloc, header_brigade);
b = header_brigade;
}
else {
@@ -570,6 +570,11 @@ static apr_status_t stream_reqbody_cl(apr_pool_t *p,
apr_bucket_brigade *b;
apr_bucket *e;
+ if (old_cl_val) {
+ add_cl(p, bucket_alloc, header_brigade, old_cl_val);
+ }
+ terminate_headers(bucket_alloc, header_brigade);
+
do {
status = ap_get_brigade(r->input_filters, input_brigade,
AP_MODE_READBYTES, APR_BLOCK_READ,
@@ -599,8 +604,6 @@ static apr_status_t stream_reqbody_cl(apr_pool_t *p,
/* we never sent the header brigade, so go ahead and
* take care of that now
*/
- add_cl(p, bucket_alloc, header_brigade, old_cl_val);
- terminate_headers(bucket_alloc, header_brigade);
b = header_brigade;
APR_BRIGADE_CONCAT(b, input_brigade);
header_brigade = NULL;
@@ -617,13 +620,8 @@ static apr_status_t stream_reqbody_cl(apr_pool_t *p,
if (header_brigade) {
/* we never sent the header brigade since there was no request
- * body; send it now, and only specify C-L if client specified
- * C-L: 0
+ * body; send it now
*/
- if (!strcmp(old_cl_val, "0")) {
- add_cl(p, bucket_alloc, header_brigade, old_cl_val);
- }
- terminate_headers(bucket_alloc, header_brigade);
b = header_brigade;
}
else {
@@ -641,7 +639,8 @@ static apr_status_t spool_reqbody_cl(apr_pool_t *p,
proxy_http_conn_t *p_conn,
conn_rec *origin,
apr_bucket_brigade *header_brigade,
- apr_bucket_brigade *input_brigade)
+ apr_bucket_brigade *input_brigade,
+ int force_cl)
{
int seen_eos = 0;
apr_status_t status;
@@ -735,7 +734,7 @@ static apr_status_t spool_reqbody_cl(apr_pool_t *p,
} while (!seen_eos);
- if (bytes_spooled) {
+ if (bytes_spooled || force_cl) {
add_cl(p, bucket_alloc, header_brigade, apr_off_t_toa(p, bytes_spooled));
}
terminate_headers(bucket_alloc, header_brigade);
@@ -776,6 +775,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
char *url, apr_bucket_brigade *bb,
char *server_portstr) {
conn_rec *c = r->connection;
+ apr_bucket_alloc_t *bucket_alloc = c->bucket_alloc;
apr_bucket_brigade *input_brigade;
char *buf;
apr_bucket *e;
@@ -1036,6 +1036,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
if (!force10
&& !cl_zero
+ && (old_cl_val || old_te_val)
&& apr_table_get(r->subprocess_env, "proxy-sendchunks")) {
rb_method = RB_STREAM_CHUNKED;
}
@@ -1072,7 +1073,8 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
break;
case RB_SPOOL_CL:
status = spool_reqbody_cl(p, r, p_conn, origin, bb,
- input_brigade);
+ input_brigade, (old_cl_val != NULL)
+ || (old_te_val != NULL));
break;
default:
ap_assert(1 != 1);