From: Rainer Jung Date: Thu, 3 Oct 2013 21:50:07 +0000 (+0000) Subject: core: Add missing Reason-Phrase in HTTP response headers. X-Git-Tag: 2.5.0-alpha~4978 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a76621f9f627826c5cd35c46a9eacc5b3302c1e;p=apache core: Add missing Reason-Phrase in HTTP response headers. PR 54946. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1529014 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index a49242f5f9..fc7c3c1cc5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) core: Add missing Reason-Phrase in HTTP response headers. + PR 54946. [Rainer Jung] + *) mod_rewrite: Make rewrite websocket aware to allow proxying. PR 55598. [Chris Harris ] diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index ee01cf4b4c..38d326b543 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -760,7 +760,7 @@ static apr_status_t send_all_header_fields(header_struct *h, * handler. * Zap r->status_line if bad. */ -static void validate_status_line(request_rec *r) +static apr_status_t validate_status_line(request_rec *r) { char *end; @@ -771,15 +771,19 @@ static void validate_status_line(request_rec *r) || (end - 3) != r->status_line || (len >= 4 && ! apr_isspace(r->status_line[3]))) { r->status_line = NULL; + return APR_EGENERAL; } /* Since we passed the above check, we know that length three * is equivalent to only a 3 digit numeric http status. * RFC2616 mandates a trailing space, let's add it. */ - else if (len == 3) { + if (len == 3) { r->status_line = apr_pstrcat(r->pool, r->status_line, " ", NULL); + return APR_EGENERAL; } + return APR_SUCCESS; } + return APR_EGENERAL; } /* @@ -791,15 +795,25 @@ static void validate_status_line(request_rec *r) static void basic_http_header_check(request_rec *r, const char **protocol) { + apr_status_t rv; + if (r->assbackwards) { /* no such thing as a response protocol */ return; } - validate_status_line(r); + rv = validate_status_line(r); if (!r->status_line) { r->status_line = ap_get_status_line(r->status); + } else if (rv != APR_SUCCESS) { + /* Status line is OK but our own reason phrase + * would be preferred if defined + */ + const char *tmp = ap_get_status_line(r->status); + if (!strncmp(tmp, r->status_line, 3)) { + r->status_line = tmp; + } } /* Note that we must downgrade before checking for force responses. */