| 88 | |
| 89 | |
| 90 | def 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 | |
| 123 | def test_header_repeated_items(): |