[nginx] Upstream: fixed parsing of split status lines.
Maxim Dounin
mdounin at mdounin.ru
Tue May 19 02:46:31 UTC 2026
details: http://freenginx.org/hg/nginx/rev/2b3e6ce20c69
branches:
changeset: 9526:2b3e6ce20c69
user: Sergey Kandaurov <pluknet at nginx.com>
date: Wed Apr 29 23:02:20 2026 +0400
description:
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. The change
introduces a new field for proper backtracking on status line fallback.
Obtained from (with minor changes):
https://github.com/nginx/nginx/commit/5f86648ef8c969e98aa2f7b938472296b12055be
diffstat:
src/http/modules/ngx_http_proxy_module.c | 2 ++
src/http/modules/ngx_http_scgi_module.c | 1 +
src/http/modules/ngx_http_uwsgi_module.c | 1 +
src/http/ngx_http.h | 1 +
src/http/ngx_http_parse.c | 2 ++
5 files changed, 7 insertions(+), 0 deletions(-)
diffs (57 lines):
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1862,6 +1862,8 @@ ngx_http_proxy_process_status_line(ngx_h
u->headers_in.status_n = 200;
u->headers_in.connection_close = 1;
+ u->buffer.pos = ctx->status.line_start;
+
return NGX_OK;
}
diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c
--- a/src/http/modules/ngx_http_scgi_module.c
+++ b/src/http/modules/ngx_http_scgi_module.c
@@ -1014,6 +1014,7 @@ ngx_http_scgi_process_status_line(ngx_ht
if (rc == NGX_ERROR) {
u->process_header = ngx_http_scgi_process_header;
+ u->buffer.pos = status->line_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
--- a/src/http/modules/ngx_http_uwsgi_module.c
+++ b/src/http/modules/ngx_http_uwsgi_module.c
@@ -1245,6 +1245,7 @@ ngx_http_uwsgi_process_status_line(ngx_h
if (rc == NGX_ERROR) {
u->process_header = ngx_http_uwsgi_process_header;
+ u->buffer.pos = status->line_start;
r->state = 0;
return ngx_http_uwsgi_process_header(r);
}
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -72,6 +72,7 @@ struct ngx_http_chunked_s {
typedef struct {
ngx_uint_t http_version;
ngx_uint_t code;
+ u_char *line_start;
u_char *start;
u_char *end;
} ngx_http_status_t;
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -1663,6 +1663,8 @@ ngx_http_parse_status_line(ngx_http_requ
/* "HTTP/" */
case sw_start:
+ status->line_start = p;
+
switch (ch) {
case 'H':
state = sw_H;
More information about the nginx-devel
mailing list