Upstream: fixed parsing of split status lines

If the first response line was split across reads and it didn't appear
a status line, the portion already processed was lost.  To preserve ABI,
the change reuses r->header_name_start for proper backtracking on status
line fallback.
This commit is contained in:
Sergey Kandaurov 2026-04-29 23:02:20 +04:00 committed by Sergey Kandaurov
parent baef7fdac2
commit 39d7d0ba07
3 changed files with 15 additions and 0 deletions

View file

@ -1752,6 +1752,10 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r)
u = r->upstream;
if (r->state == 0) {
r->header_name_start = u->buffer.pos;
}
rc = ngx_http_parse_status_line(r, &u->buffer, &ctx->status);
if (rc == NGX_AGAIN) {
@ -1759,6 +1763,7 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r)
}
if (rc == NGX_ERROR) {
u->buffer.pos = r->header_name_start;
#if (NGX_HTTP_CACHE)

View file

@ -1028,6 +1028,10 @@ ngx_http_scgi_process_status_line(ngx_http_request_t *r)
u = r->upstream;
if (r->state == 0) {
r->header_name_start = u->buffer.pos;
}
rc = ngx_http_parse_status_line(r, &u->buffer, status);
if (rc == NGX_AGAIN) {
@ -1036,6 +1040,7 @@ ngx_http_scgi_process_status_line(ngx_http_request_t *r)
if (rc == NGX_ERROR) {
u->process_header = ngx_http_scgi_process_header;
u->buffer.pos = r->header_name_start;
r->state = 0;
return ngx_http_scgi_process_header(r);
}

View file

@ -1267,6 +1267,10 @@ ngx_http_uwsgi_process_status_line(ngx_http_request_t *r)
u = r->upstream;
if (r->state == 0) {
r->header_name_start = u->buffer.pos;
}
rc = ngx_http_parse_status_line(r, &u->buffer, status);
if (rc == NGX_AGAIN) {
@ -1275,6 +1279,7 @@ ngx_http_uwsgi_process_status_line(ngx_http_request_t *r)
if (rc == NGX_ERROR) {
u->process_header = ngx_http_uwsgi_process_header;
u->buffer.pos = r->header_name_start;
r->state = 0;
return ngx_http_uwsgi_process_header(r);
}