From 39d7d0ba0799fcff6baee52b6525f45739593cfd Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Wed, 29 Apr 2026 23:02:20 +0400 Subject: [PATCH] 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. --- src/http/modules/ngx_http_proxy_module.c | 5 +++++ src/http/modules/ngx_http_scgi_module.c | 5 +++++ src/http/modules/ngx_http_uwsgi_module.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index 0b388b30f..276cc0750 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -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) diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c index 290394a1f..b4a73a5a6 100644 --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -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); } diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c index 4140b1b40..ecd6dd0d7 100644 --- a/src/http/modules/ngx_http_uwsgi_module.c +++ b/src/http/modules/ngx_http_uwsgi_module.c @@ -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); }