(sanic, loop)
| 10 | |
| 11 | @app.listener("after_server_start") |
| 12 | async def _request(sanic, loop): |
| 13 | nonlocal lines |
| 14 | connect = asyncio.open_connection("127.0.0.1", 42101) |
| 15 | reader, writer = await connect |
| 16 | writer.write(b"not http\r\n\r\n") |
| 17 | while True: |
| 18 | line = await reader.readline() |
| 19 | if not line: |
| 20 | break |
| 21 | lines.append(line) |
| 22 | app.stop() |
| 23 | |
| 24 | app.run(host="127.0.0.1", port=42101, debug=False, single_process=True) |
| 25 | assert lines[0] == b"HTTP/1.1 400 Bad Request\r\n" |