changeset 6589:78533a74af11

HTTP/2: avoid adding Content-Length for requests without body. 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.
author Valentin Bartenev <vbart@nginx.com>
date Thu, 16 Jun 2016 20:55:11 +0300
parents dc5eaf998b96
children d375f4210e41
files src/http/v2/ngx_http_v2.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/v2/ngx_http_v2.c	Thu Jun 16 20:55:11 2016 +0300
+++ b/src/http/v2/ngx_http_v2.c	Thu Jun 16 20:55:11 2016 +0300
@@ -3424,7 +3424,9 @@
         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 @@
             rb->buf = NULL;
         }
 
-        if (r->headers_in.content_length_n == -1) {
+        if (r->headers_in.chunked) {
             r->headers_in.content_length_n = rb->received;
         }