Patch and test for keepalive and chunked transfer-encoding

This commit is contained in:
Gregory Holt
2010-01-21 16:24:50 +00:00
parent dcaf551256
commit 1c68efeb50
2 changed files with 19 additions and 0 deletions

View File

@@ -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)

View File

@@ -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()