From: Yann Ylavic Date: Fri, 13 Apr 2018 07:58:51 +0000 (+0000) Subject: mod_xml2enc: Fix forwarding of error metadata/responses. PR 62180. X-Git-Tag: 2.5.0-alpha2-ci-test-only~2687 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c12ad33bb4ba9b96ca0712fbe499d91e2fc1b89c;p=thirdparty%2Fapache%2Fhttpd.git mod_xml2enc: Fix forwarding of error metadata/responses. PR 62180. All meta buckets are now aggregated (besides FLUSH) and forwarded down the chain, and the output filter bails out on EOS. Proposed by: Micha Lenk git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1829038 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 4db111242f0..6057eec2d6f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.1 + *) mod_xml2enc: Fix forwarding of error metadata/responses. PR 62180. + [Micha Lenk , Yann Ylavic] + *) mod_proxy_http: Add new worker parameter 'responsefieldsize' to allow maximum HTTP response header size to be increased past 8192 bytes. PR62199. [Hank Ibell ] diff --git a/modules/filters/mod_xml2enc.c b/modules/filters/mod_xml2enc.c index 72d3741c00e..ea7f0842e49 100644 --- a/modules/filters/mod_xml2enc.c +++ b/modules/filters/mod_xml2enc.c @@ -309,6 +309,7 @@ static apr_status_t xml2enc_ffunc(ap_filter_t* f, apr_bucket_brigade* bb) apr_bucket* b; apr_bucket* bstart; apr_size_t insz = 0; + int pending_meta = 0; char *ctype; char *p; @@ -400,16 +401,35 @@ static apr_status_t xml2enc_ffunc(ap_filter_t* f, apr_bucket_brigade* bb) ctx->bytes = 0; if (APR_BUCKET_IS_METADATA(b)) { APR_BUCKET_REMOVE(b); + APR_BRIGADE_INSERT_TAIL(ctx->bbnext, b); + /* This resource filter is over on EOS */ if (APR_BUCKET_IS_EOS(b)) { - /* send remaining data */ - APR_BRIGADE_INSERT_TAIL(ctx->bbnext, b); - return ap_fflush(f->next, ctx->bbnext); - } else if (APR_BUCKET_IS_FLUSH(b)) { - ap_fflush(f->next, ctx->bbnext); + ap_remove_output_filter(f); + APR_BRIGADE_CONCAT(ctx->bbnext, bb); + rv = ap_pass_brigade(f->next, ctx->bbnext); + apr_brigade_cleanup(ctx->bbnext); + return rv; + } + /* Besides FLUSH, aggregate meta buckets to send + * them at once below. + */ + pending_meta = 1; + if (!APR_BUCKET_IS_FLUSH(b)) { + continue; + } + } + if (pending_meta) { + pending_meta = 0; + /* passing meta bucket down the chain */ + rv = ap_pass_brigade(f->next, ctx->bbnext); + apr_brigade_cleanup(ctx->bbnext); + if (rv != APR_SUCCESS) { + return rv; } - apr_bucket_destroy(b); + continue; } - else { /* data bucket */ + /* data bucket */ + { char* buf; apr_size_t bytes = 0; char fixbuf[BUFLEN]; @@ -514,8 +534,7 @@ static apr_status_t xml2enc_ffunc(ap_filter_t* f, apr_bucket_brigade* bb) if (rv != APR_SUCCESS) ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r, APLOGNO(01446) "ap_fflush failed"); - else - rv = ap_pass_brigade(f->next, ctx->bbnext); + apr_brigade_cleanup(ctx->bbnext); } } } else {