]> git.kaiwu.me - nginx.git/commitdiff
gRPC: narrowed special handling of "trailer only" responses
authorVinay Kumar Tokala <v.tokala@f5.com>
Wed, 22 Jul 2026 06:23:09 +0000 (23:23 -0700)
committerVinay Kumar Tokala <vinaykumar1591@gmail.com>
Wed, 5 Aug 2026 03:44:23 +0000 (09:14 +0530)
Previously, the response length was explicitly set to zero if the
initial HEADERS frame was seen with the END_STREAM flag.  This was
meant to properly pass responses in the Trailers-Only format as
introduced in 6559a420134b.  This handling was too broad though,
passing incomplete responses that carry a non-zero Content-Length
to the client as if they were complete and empty.

Now such responses are caught by the existing checks later on and
are passed as incomplete, similarly to how this is handled elsewhere.
For instance, on HTTP/2 client connections this now results in proper
signalling, an incomplete stream followed by stream reset.

src/http/modules/ngx_http_grpc_module.c

index c19833fbc4ea0afa0c8f5695b6b9098535ce4fb9..3d0e9d7ee2ced047d5f5045040f95be49d9f93a6 100644 (file)
@@ -2047,7 +2047,10 @@ ngx_http_grpc_process_header(ngx_http_request_t *r)
                 }
 
                 if (ctx->end_stream) {
-                    u->headers_in.content_length_n = 0;
+
+                    if (u->headers_in.content_length_n == -1) {
+                        u->headers_in.content_length_n = 0;
+                    }
 
                     if (ctx->in == NULL
                         && ctx->out == NULL