Opened 7 years ago
Closed 7 years ago
#1443 closed defect (duplicate)
May be caused bad request when received with both a Transfer-Encoding and Content-Length header
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-core | Version: | 1.13.x |
Keywords: | Cc: | ||
uname -a: | |||
nginx -V: | before 1.13.x |
Description
May be caused bad request when received with both a Transfer-Encoding and Content-Length header.
For example:
$curl nginx.org -H "Transfer-Encoding:111" -H "Content-Length: -1" -I
HTTP/1.1 400 Bad Request
Server: nginx/1.13.3
Date: Mon, 04 Dec 2017 08:45:35 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 173
Connection: close
https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4
As described in the document above. if a Transfer-Encoding header field is present). If a message is received with both a Transfer-Encoding header field and a Content-Length header field, the latter MUST be ignored.
Fixed:
$hg diff
diff -r fc0d06224eda src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c Tue Nov 28 13:09:54 2017 +0300 +++ b/src/http/ngx_http_request.c Mon Dec 04 17:10:20 2017 +0800 @@ -1816,7 +1816,7 @@ return NGX_ERROR; } - if (r->headers_in.content_length) { + if (!r->headers_in.transfer_encoding && r->headers_in.content_length) { r->headers_in.content_length_n = ngx_atoof(r->headers_in.content_length->value.data, r->headers_in.content_length->value.len);
Duplicate of #1442.