diff --git a/eventlet/wsgi.py b/eventlet/wsgi.py index 2a89a6f..f93b6f7 100644 --- a/eventlet/wsgi.py +++ b/eventlet/wsgi.py @@ -114,6 +114,8 @@ class Input(object): else: self.chunk_length = int(rfile.readline(), 16) self.position = 0 + if not self.chunk_length: + rfile.readline() except greenio.SSL.ZeroReturnError: pass return ''.join(response) diff --git a/tests/wsgi_test.py b/tests/wsgi_test.py index a039816..246d69b 100644 --- a/tests/wsgi_test.py +++ b/tests/wsgi_test.py @@ -715,6 +715,23 @@ class TestHttpd(LimitedTestCase): response_line, headers, body = read_http(sock) self.assertEqual(headers['connection'], 'close') + def test_027_keepalive_chunked(self): + self.site.application = chunked_post + sock = api.connect_tcp(('localhost', self.port)) + fd = sock.makefile() + fd.write('PUT /a HTTP/1.1\r\nHost: localhost\r\nTransfer-Encoding: chunked\r\n\r\n10\r\n0123456789abcdef\r\n0\r\n\r\n') + fd.flush() + print 'x', read_http(sock) + fd.write('PUT /b HTTP/1.1\r\nHost: localhost\r\nTransfer-Encoding: chunked\r\n\r\n10\r\n0123456789abcdef\r\n0\r\n\r\n') + fd.flush() + print 'x', read_http(sock) + fd.write('PUT /c HTTP/1.1\r\nHost: localhost\r\nTransfer-Encoding: chunked\r\n\r\n10\r\n0123456789abcdef\r\n0\r\n\r\n') + fd.flush() + print 'x', read_http(sock) + fd.write('PUT /a HTTP/1.1\r\nHost: localhost\r\nTransfer-Encoding: chunked\r\n\r\n10\r\n0123456789abcdef\r\n0\r\n\r\n') + fd.flush() + print 'x', read_http(sock) + if __name__ == '__main__': main()