Commit 0bb70dc4 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

As Greg noted, set_keepalive has to happen before we check r->chunked, but

it also has to happen after ap_basic_http_header.  Otherwise, we don't
set r->connection->keepalive correctly, and it can be -1 for requests that
don't support keepalive.  This moves ap_basic_http_header to above the
call to set_keepalive (after reversing the previous patch), which should
be perfectly safe, while still fixing the original bug.
Submitted by:	Greg Stein


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87824 13f79535-47bb-0310-9956-ffa450edef68
parent 01645c70
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -2479,6 +2479,20 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_b
	fixup_vary(r);
    }

    /* Need to add a fudge factor so that the CRLF at the end of the headers
     * and the basic http headers don't overflow this buffer.
     */
    len += strlen(ap_get_server_version()) + 100;
    buff_start = buff = apr_pcalloc(r->pool, len);
    ap_basic_http_header(r, buff);
    buff += strlen(buff);

    h.r = r;
    h.buf = buff;


    ap_set_keepalive(r);

    if (r->chunked) {
        apr_table_mergen(r->headers_out, "Transfer-Encoding", "chunked");
        apr_table_unset(r->headers_out, "Content-Length");
@@ -2551,17 +2565,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_b
                 (void *) &len, r->headers_out, NULL);
    }
    
    /* Need to add a fudge factor so that the CRLF at the end of the headers
     * and the basic http headers don't overflow this buffer.
     */
    len += strlen(ap_get_server_version()) + 100;
    buff_start = buff = apr_pcalloc(r->pool, len);
    ap_basic_http_header(r, buff);
    buff += strlen(buff);

    h.r = r;
    h.buf = buff;

    if (r->status == HTTP_NOT_MODIFIED) {
        apr_table_do((int (*)(void *, const char *, const char *)) form_header_field,
                    (void *) &h, r->headers_out,
@@ -2584,8 +2587,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_b

    terminate_header(buff);

    ap_set_keepalive(r);

    r->sent_bodyct = 1;         /* Whatever follows is real body stuff... */

    b2 = apr_brigade_create(r->pool);