]> git.kaiwu.me - nginx.git/commitdiff
SCGI: fixed passing CONTENT_LENGTH in unbuffered mode.
authorSergey Kandaurov <pluknet@nginx.com>
Fri, 30 Jan 2026 13:06:38 +0000 (17:06 +0400)
committerSergey Kandaurov <s.kandaurov@f5.com>
Tue, 17 Feb 2026 13:45:29 +0000 (17:45 +0400)
Passing requests to SCGI uses a recalculated size of a request body
as per changes made in d60b8d10f (1.3.9) to support CONTENT_LENGTH
with chunked body requests.  This, however, is not compatible with
unbuffered mode introduced later in 7ec559df5 (1.7.11), where such
an approach may not always represent complete request body.

The fix is to use r->headers_in.content_length_n representing either
original Content-Length, if any, or a recalculated value from request
body filters, such as chunked body filter.

Reported by Mufeed VH.

src/http/modules/ngx_http_scgi_module.c

index 91f5f7ccdb00bd6f6e071b3f2190e520013dcda6..8937464b63961457f925f4a3230e76851e2de93b 100644 (file)
@@ -658,11 +658,9 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
     u_char                        buffer[NGX_OFF_T_LEN];
 
     content_length_n = 0;
-    body = r->upstream->request_bufs;
 
-    while (body) {
-        content_length_n += ngx_buf_size(body->buf);
-        body = body->next;
+    if (r->headers_in.content_length_n > 0) {
+        content_length_n = r->headers_in.content_length_n;
     }
 
     content_length.data = buffer;