(request: bytes)
| 170 | reader, writer = await asyncio.open_connection("127.0.0.1", port) |
| 171 | |
| 172 | async def extract_json_body(request: bytes): |
| 173 | writer.write(request) |
| 174 | await writer.drain() |
| 175 | |
| 176 | status, *headers = (await reader.readuntil(b"\r\n\r\n")).split(b"\r\n")[:-2] |
| 177 | assert status == b"HTTP/1.1 200 OK" |
| 178 | |
| 179 | content_length = next(int(h.split(b":", 1)[1]) for h in headers if h.lower().startswith(b"content-length:")) |
| 180 | return json.loads(await reader.readexactly(content_length)) |
| 181 | |
| 182 | try: |
| 183 | yield extract_json_body |
no test coverage detected