MCPcopy Index your code
hub / github.com/encode/httpx / test_header_update

Function test_header_update

tests/client/test_headers.py:90–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88
89
90def test_header_update():
91 url = "http://example.org/echo_headers"
92 client = httpx.Client(transport=httpx.MockTransport(echo_headers))
93 first_response = client.get(url)
94 client.headers.update(
95 {"User-Agent": "python-myclient/0.2.1", "Another-Header": "AThing"}
96 )
97 second_response = client.get(url)
98
99 assert first_response.status_code == 200
100 assert first_response.json() == {
101 "headers": {
102 "accept": "*/*",
103 "accept-encoding": "gzip, deflate, br, zstd",
104 "connection": "keep-alive",
105 "host": "example.org",
106 "user-agent": f"python-httpx/{httpx.__version__}",
107 }
108 }
109
110 assert second_response.status_code == 200
111 assert second_response.json() == {
112 "headers": {
113 "accept": "*/*",
114 "accept-encoding": "gzip, deflate, br, zstd",
115 "another-header": "AThing",
116 "connection": "keep-alive",
117 "host": "example.org",
118 "user-agent": "python-myclient/0.2.1",
119 }
120 }
121
122
123def test_header_repeated_items():

Callers

nothing calls this directly

Calls 3

getMethod · 0.95
jsonMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected