From: Bill Stoddard Date: Tue, 26 Jun 2001 17:40:58 +0000 (+0000) Subject: Fix problem handling FLUSH bucket in the chunked encoding filter. X-Git-Tag: 2.0.19~43 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=040c05592a3005a217eff3ddbaae6957fc3e8cd5;p=apache Fix problem handling FLUSH bucket in the chunked encoding filter. Module was calling ap_rwrite() followed by ap_rflush() but the served content was not being displayed in the browser. Inspection of the output stream revealed that the first data chunk was missing the trailing CRLF required by the RFC git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89422 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 4dd1824208..8b3ae483b9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ Changes with Apache 2.0.19-dev + *) Fix problem handling FLUSH bucket in the chunked encoding filter. + Module was calling ap_rwrite() followed by ap_rflush() but the + served content was not being displayed in the browser. Inspection + of the output stream revealed that the first data chunk was + missing the trailing CRLF required by the RFC. + *) apxs no longer generates ap_send_http_header() in the example handler *) Fix an ab problem which could cause a divide-by-zero exception diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 06a2c2de55..302d323938 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -144,6 +144,7 @@ static apr_status_t chunk_filter(ap_filter_t *f, apr_bucket_brigade *b) for (more = NULL; b; b = more, more = NULL) { apr_off_t bytes = 0; apr_bucket *eos = NULL; + apr_bucket *flush = NULL; char chunk_hdr[20]; /* enough space for the snprintf below */ APR_BRIGADE_FOREACH(e, b) { @@ -152,6 +153,9 @@ static apr_status_t chunk_filter(ap_filter_t *f, apr_bucket_brigade *b) eos = e; break; } + if (APR_BUCKET_IS_FLUSH(e)) { + flush = e; + } else if (e->length == -1) { /* unknown amount of data (e.g. a pipe) */ const char *data; @@ -206,13 +210,16 @@ static apr_status_t chunk_filter(ap_filter_t *f, apr_bucket_brigade *b) APR_BRIGADE_INSERT_HEAD(b, e); /* - * Insert the end-of-chunk CRLF before the EOS bucket, or - * appended to the brigade + * Insert the end-of-chunk CRLF before an EOS or + * FLUSH bucket, or appended to the brigade */ e = apr_bucket_immortal_create(ASCII_CRLF, 2); if (eos != NULL) { APR_BUCKET_INSERT_BEFORE(eos, e); } + else if (flush != NULL) { + APR_BUCKET_INSERT_BEFORE(flush, e); + } else { APR_BRIGADE_INSERT_TAIL(b, e); }