# HG changeset patch # User Valentin Bartenev # Date 1466099711 -10800 # Node ID 12b1df4c99445a60c7bf0b214af5f196497eb97e # Parent 20485a482bc016f4968844b3346d5e9345f263f4 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. diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c --- a/src/http/v2/ngx_http_v2.c +++ b/src/http/v2/ngx_http_v2.c @@ -3424,7 +3424,9 @@ ngx_http_v2_run_request(ngx_http_request 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_htt rb->buf = NULL; } - if (r->headers_in.content_length_n == -1) { + if (r->headers_in.chunked) { r->headers_in.content_length_n = rb->received; }