Commit 05a9a42a authored by Bill Stoddard's avatar Bill Stoddard
Browse files

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
parent 95ab2b3a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
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
+9 −2
Original line number Diff line number Diff line
@@ -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);
            }