[nginx] SCGI: fixed handling of unbuffered request body.
Maxim Dounin
mdounin at mdounin.ru
Mon May 18 00:42:51 UTC 2026
details: http://freenginx.org/hg/nginx/rev/f84effafce4a
branches:
changeset: 9516:f84effafce4a
user: Maxim Dounin <mdounin at mdounin.ru>
date: Mon May 18 03:41:05 2026 +0300
description:
SCGI: fixed handling of unbuffered request body.
Previously, size of the request body as sent in the CONTENT_LENGTH param
was calculated based on the size of the request buffers available. This is,
however, wrong for unbuffered request body, since the request body might
not be fully available yet.
The fix is to use r->headers_in.content_length_n (as long as it is available
and there is a body), much like other modules do.
See also:
https://github.com/nginx/nginx/commit/ec714d52bd4914d52a113234c16e1855d9ac7dcf
diffstat:
src/http/modules/ngx_http_scgi_module.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diffs (18 lines):
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
@@ -649,11 +649,9 @@ ngx_http_scgi_create_request(ngx_http_re
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 && !r->discard_body) {
+ content_length_n = r->headers_in.content_length_n;
}
content_length.data = buffer;
More information about the nginx-devel
mailing list