Reads an HTTP response from `stream` and returns a tuple of its start_line, headers and body.
(stream)
| 53 | |
| 54 | |
| 55 | async 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 | |
| 77 | class HandlerBaseTestCase(AsyncHTTPTestCase): |
no test coverage detected