MCPcopy
hub / github.com/tornadoweb/tornado / read_stream_body

Function read_stream_body

tornado/test/httpserver_test.py:55–74  ·  view source on GitHub ↗

Reads an HTTP response from `stream` and returns a tuple of its start_line, headers and body.

(stream)

Source from the content-addressed store, hash-verified

53
54
55async def read_stream_body(stream):
56 """Reads an HTTP response from `stream` and returns a tuple of its
57 start_line, headers and body."""
58 chunks = []
59
60 class Delegate(HTTPMessageDelegate):
61 def headers_received(self, start_line, headers):
62 self.headers = headers
63 self.start_line = start_line
64
65 def data_received(self, chunk):
66 chunks.append(chunk)
67
68 def finish(self):
69 conn.detach() # type: ignore
70
71 conn = HTTP1Connection(stream, True)
72 delegate = Delegate()
73 await conn.read_response(delegate)
74 return delegate.start_line, delegate.headers, b"".join(chunks)
75
76
77class HandlerBaseTestCase(AsyncHTTPTestCase):

Calls 4

read_responseMethod · 0.95
HTTP1ConnectionClass · 0.90
joinMethod · 0.80
DelegateClass · 0.70

Tested by

no test coverage detected