yaoweibin / ngx_http_substitutions_filter_module

a filter module which can do both regular expression and fixed string substitutions for nginx
607 stars 213 forks source link

HTTP 1.0 responses are HTTP 1.1 and broken: content-length and transfer-encoding header is missing. #26

Open niko opened 6 years ago

niko commented 6 years ago

When doing HTTP 1.1 requests ngx_http_substitutions_filter_module removes the content-length header and adds transfer-encoding: chunked. That's perfectly fine.

When doing HTTP 1.0 requests ngx_http_substitutions_filter_module just removes the content-length header while still announcing a HTTP 1.1 response.

curl -i0 172.17.104.12/station/eins 
*   Trying 172.17.104.12...
* Connected to 172.17.104.12 (172.17.104.12) port 80 (#0)
> GET /station/eins HTTP/1.0
> Host: 172.17.104.12
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 09 Nov 2017 13:30:04 GMT
Content-Type: application/json; charset=utf-8
Connection: close
Vary: Accept-Encoding
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: ANY
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 1728000
Cache-Control: public, must-revalidate, max-age=3582
Expires: Thu, 09 Nov 2017 14:00:14 GMT
X-FRONTEND: http
X-BACKEND: api_backend
X-BACKEND-SERVER: api_172.17.104.8:3000
X-Varnish: 17730207 17302980
Age: 1773
Via: 1.1 varnish-v4
Location: 
X-Cache: HIT
X-Cache-Hits: 78
Accept-Ranges: bytes

[body]

(note that I have mixed the output of curl and curl -v for clarity)

You can see that curl issues a HTTP 1.0 request and gets a broken HTTP 1.1 answer.

Some clients (we have user reports of PHPs file_gets_content) break with a response like that.

We're using bc58cb11844bc42735bbaef7085ea86ace46d05b.