From b7ba872c74c52934dab452895d6baed85fe3b5e7 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Wed, 24 Jan 2001 23:47:42 +0000 Subject: [PATCH] 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 --- modules/http/http_protocol.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index cd6684b1ec..48f2d877e3 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -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); -- 2.40.0