HTTP: fixed status line format for unknown status codes.
According to Section #3.1.2 of RFC 7230, after the status code there must be a space even if the reason phrase is empty. Also, only 3 digits allowed. This closes #507 issue on GitHub.
This commit is contained in:
@@ -9,6 +9,12 @@
|
|||||||
date="" time="18:00:00 +0300"
|
date="" time="18:00:00 +0300"
|
||||||
packager="Andrei Belov <defan@nginx.com>">
|
packager="Andrei Belov <defan@nginx.com>">
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para>
|
||||||
|
invalid HTTP responses were generated for some unusual status codes.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
</changes>
|
</changes>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1151,13 +1151,13 @@ static const nxt_str_t nxt_http_client_error[] = {
|
|||||||
nxt_string("HTTP/1.1 415 Unsupported Media Type\r\n"),
|
nxt_string("HTTP/1.1 415 Unsupported Media Type\r\n"),
|
||||||
nxt_string("HTTP/1.1 416 Range Not Satisfiable\r\n"),
|
nxt_string("HTTP/1.1 416 Range Not Satisfiable\r\n"),
|
||||||
nxt_string("HTTP/1.1 417 Expectation Failed\r\n"),
|
nxt_string("HTTP/1.1 417 Expectation Failed\r\n"),
|
||||||
nxt_string("HTTP/1.1 418\r\n"),
|
nxt_string("HTTP/1.1 418 I'm a teapot\r\n"),
|
||||||
nxt_string("HTTP/1.1 419 \r\n"),
|
nxt_string("HTTP/1.1 419 \r\n"),
|
||||||
nxt_string("HTTP/1.1 420 \r\n"),
|
nxt_string("HTTP/1.1 420 \r\n"),
|
||||||
nxt_string("HTTP/1.1 421\r\n"),
|
nxt_string("HTTP/1.1 421 Misdirected Request\r\n"),
|
||||||
nxt_string("HTTP/1.1 422\r\n"),
|
nxt_string("HTTP/1.1 422 Unprocessable Entity\r\n"),
|
||||||
nxt_string("HTTP/1.1 423\r\n"),
|
nxt_string("HTTP/1.1 423 Locked\r\n"),
|
||||||
nxt_string("HTTP/1.1 424\r\n"),
|
nxt_string("HTTP/1.1 424 Failed Dependency\r\n"),
|
||||||
nxt_string("HTTP/1.1 425 \r\n"),
|
nxt_string("HTTP/1.1 425 \r\n"),
|
||||||
nxt_string("HTTP/1.1 426 Upgrade Required\r\n"),
|
nxt_string("HTTP/1.1 426 Upgrade Required\r\n"),
|
||||||
nxt_string("HTTP/1.1 427 \r\n"),
|
nxt_string("HTTP/1.1 427 \r\n"),
|
||||||
@@ -1190,7 +1190,7 @@ static const nxt_str_t nxt_http_server_error[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 65536\r\n")
|
#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 999 \r\n")
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
|
nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
|
||||||
@@ -1248,13 +1248,16 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
|
|||||||
{
|
{
|
||||||
status = &nxt_http_server_error[n - NXT_HTTP_INTERNAL_SERVER_ERROR];
|
status = &nxt_http_server_error[n - NXT_HTTP_INTERNAL_SERVER_ERROR];
|
||||||
|
|
||||||
} else {
|
} else if (n <= NXT_HTTP_STATUS_MAX) {
|
||||||
p = nxt_sprintf(buf, buf + UNKNOWN_STATUS_LENGTH,
|
(void) nxt_sprintf(buf, buf + UNKNOWN_STATUS_LENGTH,
|
||||||
"HTTP/1.1 %03d \r\n", n);
|
"HTTP/1.1 %03d \r\n", n);
|
||||||
|
|
||||||
unknown_status.length = p - buf;
|
unknown_status.length = UNKNOWN_STATUS_LENGTH;
|
||||||
unknown_status.start = buf;
|
unknown_status.start = buf;
|
||||||
status = &unknown_status;
|
status = &unknown_status;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
status = &nxt_http_server_error[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
size = status->length;
|
size = status->length;
|
||||||
|
|||||||
Reference in New Issue
Block a user