diff options
author | Yann Ylavic <ylavic@apache.org> | 2016-11-15 10:06:55 +0100 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2016-11-15 10:06:55 +0100 |
commit | ef6e478b7831e43f475c47920c52a278e5359000 (patch) | |
tree | 585d418440e2ea1bd79d526d5fdaf3877bb0a624 /modules/http/http_protocol.c | |
parent | Fix some HTML tags (diff) | |
download | apache2-ef6e478b7831e43f475c47920c52a278e5359000.tar.xz apache2-ef6e478b7831e43f475c47920c52a278e5359000.zip |
http: Allow unknown response status' lines returned in the form of:
HTTP/x.x xxx Status xxx
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1769760 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | modules/http/http_protocol.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index b590fa5f29..d7b995d0d4 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -801,14 +801,17 @@ AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum) * from status_lines[shortcut[i]] to status_lines[shortcut[i+1]-1]; * or use NULL to fill the gaps. */ -AP_DECLARE(int) ap_index_of_response(int status) +static int index_of_response(int status) { - static int shortcut[6] = {0, LEVEL_200, LEVEL_300, LEVEL_400, - LEVEL_500, RESPONSE_CODES}; + static int shortcut[6] = {0, LEVEL_200, LEVEL_300, LEVEL_400, LEVEL_500, + RESPONSE_CODES}; int i, pos; - if (status < 100) { /* Below 100 is illegal for HTTP status */ - return LEVEL_500; + if (status < 100) { /* Below 100 is illegal for HTTP status */ + return -1; + } + if (status > 999) { /* Above 999 is also illegal for HTTP status */ + return -1; } for (i = 0; i < 5; i++) { @@ -819,11 +822,31 @@ AP_DECLARE(int) ap_index_of_response(int status) return pos; } else { - return LEVEL_500; /* status unknown (falls in gap) */ + break; } } } - return LEVEL_500; /* 600 or above is also illegal */ + return 0; /* Status unknown (falls in gap) or above 600 */ +} + +AP_DECLARE(int) ap_index_of_response(int status) +{ + int index = index_of_response(status); + return (index <= 0) ? LEVEL_500 : index; +} + +AP_DECLARE(const char *) ap_get_status_line_ex(apr_pool_t *p, int status) +{ + int index = index_of_response(status); + if (index < 0) { + return status_lines[LEVEL_500]; + } + else if (index == 0) { + return apr_psprintf(p, "%i Status %i", status, status); + } + else { + return status_lines[index]; + } } AP_DECLARE(const char *) ap_get_status_line(int status) |