Closing upstream keepalive connections in an invalid state

Chris Branch x at chrisbranch.co.uk
Mon Nov 30 15:20:17 UTC 2015


There was a thread on the nginx mailing list last week, regarding upstream keepalive connections being placed in an invalid state due to a partially-transmitted request body. With regard to that discussion, I’m submitting two patches for your review.

The first adds a test case to nginx-tests demonstrating the problem as of nginx 1.9.7. Most of the change involves extending the mock origin to consume a request body, and verify the method transmitted. Currently, nginx will reuse the upstream connection for a subsequent request and (from the point of view of an upstream client) insert some or all of a request line and headers into the previous request's body. The result is typically a 400 Bad Request error due to a malformed request.

The second patch fixes this bug using the method suggested by Maxim, i.e. close the upstream connection when a response is received before the request body is completely sent. This is the behaviour suggested in RFC 2616 section 8.2.2. The relevant Trac issue is #669.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx-fix-bad-request.patch
Type: application/octet-stream
Size: 623 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20151130/67039c93/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx-tests.patch
Type: application/octet-stream
Size: 2639 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20151130/67039c93/attachment-0001.obj>


More information about the nginx-devel mailing list