(test_client_factory: TestClientFactory)
| 80 | reason='urllib3 includes "br" to the "accept-encoding" headers.', |
| 81 | ) |
| 82 | def test_websocket_headers(test_client_factory: TestClientFactory) -> None: |
| 83 | async def app(scope: Scope, receive: Receive, send: Send) -> None: |
| 84 | websocket = WebSocket(scope, receive=receive, send=send) |
| 85 | headers = dict(websocket.headers) |
| 86 | await websocket.accept() |
| 87 | await websocket.send_json({"headers": headers}) |
| 88 | await websocket.close() |
| 89 | |
| 90 | client = test_client_factory(app) |
| 91 | with client.websocket_connect("/") as websocket: |
| 92 | expected_headers = { |
| 93 | "accept": "*/*", |
| 94 | "accept-encoding": "gzip, deflate, zstd", |
| 95 | "connection": "upgrade", |
| 96 | "host": "testserver", |
| 97 | "user-agent": "testclient", |
| 98 | "sec-websocket-key": "testserver==", |
| 99 | "sec-websocket-version": "13", |
| 100 | } |
| 101 | data = websocket.receive_json() |
| 102 | assert data == {"headers": expected_headers} |
| 103 | |
| 104 | |
| 105 | def test_websocket_port(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected