Upstream: fixed handling of Status headers without reason-phrase.

Status header with an empty reason-phrase, such as "Status: 404 ", is
valid per CGI specification, but looses the trailing space during parsing.
Currently, this results in "HTTP/1.1 404" HTTP status line in the response,
which violates HTTP specification due to missing trailing space.

With this change, only the status code is used from such short Status
header lines, so nginx will generate status line itself, with the space
and appropriate reason phrase if available.

Reported at:
https://mailman.nginx.org/pipermail/nginx/2023-August/EX7G4JUUHJWJE5UOAZMO5UD6OJILCYGX.html
This commit is contained in:
Maxim Dounin 2023-08-31 22:59:17 +03:00
parent ba30ff4c8d
commit fa46a57199
3 changed files with 12 additions and 3 deletions

View File

@ -2048,7 +2048,10 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
}
u->headers_in.status_n = status;
u->headers_in.status_line = *status_line;
if (status_line->len > 3) {
u->headers_in.status_line = *status_line;
}
} else if (u->headers_in.location) {
u->headers_in.status_n = 302;

View File

@ -1153,7 +1153,10 @@ ngx_http_scgi_process_header(ngx_http_request_t *r)
}
u->headers_in.status_n = status;
u->headers_in.status_line = *status_line;
if (status_line->len > 3) {
u->headers_in.status_line = *status_line;
}
} else if (u->headers_in.location) {
u->headers_in.status_n = 302;

View File

@ -1381,7 +1381,10 @@ ngx_http_uwsgi_process_header(ngx_http_request_t *r)
}
u->headers_in.status_n = status;
u->headers_in.status_line = *status_line;
if (status_line->len > 3) {
u->headers_in.status_line = *status_line;
}
} else if (u->headers_in.location) {
u->headers_in.status_n = 302;