From: Yann Ylavic Date: Thu, 14 Feb 2019 08:22:49 +0000 (+0000) Subject: mod_proxy_http: follow up to r1853409: don't play with meta-buckets. X-Git-Tag: 2.5.0-alpha2-ci-test-only~2160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8633aa28dc04dbd27cd7c63c8db4cda1095af5f;p=thirdparty%2Fapache%2Fhttpd.git mod_proxy_http: follow up to r1853409: don't play with meta-buckets. It's better/simpler to handle the final 0-size chunk within the loop (on EOS). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853561 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index 9eb2754ae77..06f3ace5a74 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -337,6 +337,9 @@ static int stream_reqbody_chunked(proxy_http_req_t *req) apr_brigade_length(input_brigade, 1, &bytes); if (bytes) { + /* + * Prepend the size of the chunk + */ hdr_len = apr_snprintf(chunk_hdr, sizeof(chunk_hdr), "%" APR_UINT64_T_HEX_FMT CRLF, (apr_uint64_t)bytes); @@ -351,16 +354,16 @@ static int stream_reqbody_chunked(proxy_http_req_t *req) e = apr_bucket_immortal_create(CRLF_ASCII, 2, bucket_alloc); APR_BRIGADE_INSERT_TAIL(input_brigade, e); } - else if (APR_BRIGADE_EMPTY(header_brigade)) { - if (!seen_eos) { - /* Metadata only (shouldn't happen), read more */ - apr_brigade_cleanup(input_brigade); - continue; - } - /* At EOS, we are done since the trailing 0-size is handled - * outside this loop. + + if (seen_eos) { + /* + * Append the tailing 0-size chunk */ - break; + e = apr_bucket_immortal_create(ZERO_ASCII CRLF_ASCII + /* */ + CRLF_ASCII, + 5, bucket_alloc); + APR_BRIGADE_INSERT_TAIL(input_brigade, e); } } @@ -369,22 +372,14 @@ static int stream_reqbody_chunked(proxy_http_req_t *req) */ APR_BRIGADE_PREPEND(input_brigade, header_brigade); - /* No flush here since it's done either on the next loop depending - * on stream_reqbody_read(), or after the loop with the EOS chunk. - */ + /* Flush here on EOS because we won't stream_reqbody_read() again */ rv = ap_proxy_pass_brigade(bucket_alloc, r, p_conn, req->origin, - input_brigade, 0); + input_brigade, seen_eos); if (rv != OK) { return rv; } } while (!seen_eos); - e = apr_bucket_immortal_create(ZERO_ASCII CRLF_ASCII - /* */ - CRLF_ASCII, - 5, bucket_alloc); - APR_BRIGADE_INSERT_TAIL(input_brigade, e); - if (apr_table_get(r->subprocess_env, "proxy-sendextracrlf")) { e = apr_bucket_immortal_create(CRLF_ASCII, 2, bucket_alloc); APR_BRIGADE_INSERT_TAIL(input_brigade, e);