MCPcopy Create free account
hub / github.com/EasyIME/PIME / read_stream_body

Function read_stream_body

python/python3/tornado/test/httpserver_test.py:54–73  ·  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

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

Calls 4

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

Tested by

no test coverage detected