]> git.kaiwu.me - nginx.git/commitdiff
Upstream: fixed parsing of split status lines
authorSergey Kandaurov <pluknet@nginx.com>
Wed, 29 Apr 2026 19:02:20 +0000 (23:02 +0400)
committerSergey Kandaurov <s.kandaurov@f5.com>
Wed, 13 May 2026 17:19:47 +0000 (21:19 +0400)
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.

src/http/modules/ngx_http_proxy_module.c
src/http/modules/ngx_http_scgi_module.c
src/http/modules/ngx_http_uwsgi_module.c
src/http/ngx_http.h
src/http/ngx_http_parse.c

index e33dc37fdf0ba0cc0d463fb4edf639741e274a07..7e08df702a73e6dbc7d09901a0ac83a3f4c66d05 100644 (file)
@@ -1761,6 +1761,7 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r)
     }
 
     if (rc == NGX_ERROR) {
+        u->buffer.pos = ctx->status.line_start;
 
 #if (NGX_HTTP_CACHE)
 
index 290394a1fe14cc9d75abdd082ed6fe9645c3ccc7..406b5f88fc5753931bd4aba50542f48b61026496 100644 (file)
@@ -1036,6 +1036,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 = status->line_start;
         r->state = 0;
         return ngx_http_scgi_process_header(r);
     }
index 4140b1b4041c4c7cec3cbaf69f8a6f313f84296a..cb03ca77c4877f2bbb1ea4fab37618b97f56d821 100644 (file)
@@ -1275,6 +1275,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 = status->line_start;
         r->state = 0;
         return ngx_http_uwsgi_process_header(r);
     }
index 4e4511cc5204ff947c2516cef424ec9e4b8db104..1b0e369f3bcfdf207921949cfa176b2bc2ed2b38 100644 (file)
@@ -72,6 +72,7 @@ typedef struct {
     ngx_uint_t           http_version;
     ngx_uint_t           code;
     ngx_uint_t           count;
+    u_char              *line_start;
     u_char              *start;
     u_char              *end;
 } ngx_http_status_t;
index ac10f561a35f1ca2f4660894ccf4b5ee81a1bff3..e1328da049e66d82491a1df467df3a6c62e107b8 100644 (file)
@@ -1703,6 +1703,8 @@ ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b,
 
         /* "HTTP/" */
         case sw_start:
+            status->line_start = p;
+
             switch (ch) {
             case 'H':
                 state = sw_H;