def test_unknownContentLength(self):
"""
If a response does not include a I{Transfer-Encoding} or a
I{Content-Length}, the end of response body is indicated by the
connection being closed.
"""
finished = []
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None), finished.append)
transport = StringTransport()
protocol.makeConnection(transport)
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
body = []
protocol.response._bodyDataReceived = body.append
protocol.dataReceived(b'\r\n')
protocol.dataReceived(b'foo')
protocol.dataReceived(b'bar')
self.assertEqual(body, [b'foo', b'bar'])
protocol.connectionLost(ConnectionDone(u"simulated end of connection"))
self.assertEqual(finished, [b''])
评论列表
文章目录