From 6589832d5753788e14f9cbd1d03e0a1bdc636be0 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 8 Oct 2013 14:18:44 +0000 Subject: [PATCH] Merge r1529014 from trunk: core: Add missing Reason-Phrase in HTTP response headers. PR 54946. Submitted by: rjung Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1530280 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ STATUS | 5 ----- modules/http/http_filters.c | 20 +++++++++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 34becc03ef..55cc9c95cd 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.4.7 + *) 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/STATUS b/STATUS index 074f2aaba8..5a6f0e4a15 100644 --- a/STATUS +++ b/STATUS @@ -103,11 +103,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: 2.4.x patch: http://people.apache.org/~druggeri/patches/SessionCryptoPassphrase-exec.2.4.x.patch +1: druggeri, rjung, jim - * core: Add missing Reason-Phrase in HTTP response headers. - PR 54946. - trunk patches: https://svn.apache.org/r1529014 - 2.4.x: trunk works modulo CHANGES - +1: rjung, covener, jim PATCHES PROPOSED TO BACKPORT FROM TRUNK: diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index 24a939a45c..c727419453 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -825,7 +825,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; @@ -836,15 +836,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; } /* @@ -856,15 +860,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. */ -- 2.40.0