]> git.kaiwu.me - nginx.git/commitdiff
HTTP/2: avoid adding Content-Length for requests without body.
authorValentin Bartenev <vbart@nginx.com>
Thu, 16 Jun 2016 17:55:11 +0000 (20:55 +0300)
committerValentin Bartenev <vbart@nginx.com>
Thu, 16 Jun 2016 17:55:11 +0000 (20:55 +0300)
There is no reason to add the "Content-Length: 0" header to a proxied request
without body if the header isn't presented in the original request.

Thanks to Amazon.

src/http/v2/ngx_http_v2.c

index 99cb3fc70cd87595bcd99674d5ea362ab767d63d..342c307ef375e7e4ce3b47953358973d95d4bbd4 100644 (file)
@@ -3424,7 +3424,9 @@ ngx_http_v2_run_request(ngx_http_request_t *r)
         return;
     }
 
-    r->headers_in.chunked = (r->headers_in.content_length_n == -1);
+    if (r->headers_in.content_length_n == -1 && !r->stream->in_closed) {
+        r->headers_in.chunked = 1;
+    }
 
     ngx_http_process_request(r);
 }
@@ -3638,7 +3640,7 @@ ngx_http_v2_process_request_body(ngx_http_request_t *r, u_char *pos,
             rb->buf = NULL;
         }
 
-        if (r->headers_in.content_length_n == -1) {
+        if (r->headers_in.chunked) {
             r->headers_in.content_length_n = rb->received;
         }