I’ve discovered what I believe to be a bug (yeah I know everyone is
already
rolling their eyes)
I believe that my CGI is returning some data (perhaps Content-Type
header)
and then is occasionally stalling due to backend load.
This is fine, and fastcgi_read_timeout can be adjusted to deal with the
issue of course.
However, it appears that when Nginx times out the connection it still
serves
a non-empty Content-Length!
HTTP/1.1 200 OK^M
Server: nginx/1.2.6^M
Date: Tue, 05 Feb 2013 20:12:31 GMT^M
Content-Type: text/x-json^M
Content-Length: 397^M
Connection: keep-alive^M
X-WSL-Version: 1.0^M
^M
HTTP/1.1 200 OK^M
Server: nginx/1.2.6^M
Date: Tue, 05 Feb 2013 20:12:38 GMT^M
Content-Type: text/x-json^M
Content-Length: 396^M
Connection: keep-alive^M
^M
(There is actual JSON data here, I clipped it out, trust me!)
See that 397 bytes of non-existent data?
I tested on nginx/0.8.53 and nginx/1.2.6. I’m using netcat6 to run the
tests
with http-pipelining.
I also tried various different kernels, and ran the tests on my local
network to rule out weird internet stuff.
Posted at Nginx Forum: