MCPcopy
hub / github.com/encode/httpx / test_header_update

Function test_header_update

tests/client/test_headers.py:90–120  ·  tests/client/test_headers.py::test_header_update
()

Source from the content-addressed store, hash-verified

88
89
90def test_header_update():
91 url = class="st">"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 {class="st">"User-Agent": class="st">"python-myclient/0.2.1", class="st">"Another-Header": class="st">"AThing"}
96 )
97 second_response = client.get(url)
98
99 assert first_response.status_code == 200
100 assert first_response.json() == {
101 class="st">"headers": {
102 class="st">"accept": class="st">"*/*",
103 class="st">"accept-encoding": class="st">"gzip, deflate, br, zstd",
104 class="st">"connection": class="st">"keep-alive",
105 class="st">"host": class="st">"example.org",
106 class="st">"user-agent": fclass="st">"python-httpx/{httpx.__version__}",
107 }
108 }
109
110 assert second_response.status_code == 200
111 assert second_response.json() == {
112 class="st">"headers": {
113 class="st">"accept": class="st">"*/*",
114 class="st">"accept-encoding": class="st">"gzip, deflate, br, zstd",
115 class="st">"another-header": class="st">"AThing",
116 class="st">"connection": class="st">"keep-alive",
117 class="st">"host": class="st">"example.org",
118 class="st">"user-agent": class="st">"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