MCPcopy Index your code
hub / github.com/encode/starlette / test_request_headers

Function test_request_headers

tests/test_requests.py:48–65  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

46 reason='urllib3 includes "br" to the "accept-encoding" headers.',
47)
48def test_request_headers(test_client_factory: TestClientFactory) -> None:
49 async def app(scope: Scope, receive: Receive, send: Send) -> None:
50 request = Request(scope, receive)
51 headers = dict(request.headers)
52 response = JSONResponse({"headers": headers})
53 await response(scope, receive, send)
54
55 client = test_client_factory(app)
56 response = client.get("/", headers={"host": "example.org"})
57 assert response.json() == {
58 "headers": {
59 "host": "example.org",
60 "user-agent": "testclient",
61 "accept-encoding": "gzip, deflate, zstd",
62 "accept": "*/*",
63 "connection": "keep-alive",
64 }
65 }
66
67
68@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected