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