[PATCH 10 of 10] Upstream: fixed parsing of split status lines
Maxim Dounin
mdounin at mdounin.ru
Sun May 17 00:12:43 UTC 2026
# HG changeset patch
# User Sergey Kandaurov <pluknet at nginx.com>
# Date 1777489340 -14400
# Wed Apr 29 23:02:20 2026 +0400
# Node ID b454cd489cfd4e42ba3d45e0f34587bedd6cd463
# Parent f4515f0ba7bcf8f0c7ed6e4e2024c051b39c31f1
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
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
@@ -1016,6 +1016,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