(test_client_factory: TestClientFactory)
| 80 | reason=&class="cm">#x27;urllib3 includes class="st">"br" to the class="st">"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({class="st">"headers": headers}) |
| 88 | await websocket.close() |
| 89 | |
| 90 | client = test_client_factory(app) |
| 91 | with client.websocket_connect(class="st">"/") as websocket: |
| 92 | expected_headers = { |
| 93 | class="st">"accept": class="st">"*/*", |
| 94 | class="st">"accept-encoding": class="st">"gzip, deflate, zstd", |
| 95 | class="st">"connection": class="st">"upgrade", |
| 96 | class="st">"host": class="st">"testserver", |
| 97 | class="st">"user-agent": class="st">"testclient", |
| 98 | class="st">"sec-websocket-key": class="st">"testserver==", |
| 99 | class="st">"sec-websocket-version": class="st">"13", |
| 100 | } |
| 101 | data = websocket.receive_json() |
| 102 | assert data == {class="st">"headers": expected_headers} |
| 103 | |
| 104 | |
| 105 | def test_websocket_port(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected