@@ -141,20 +141,21 @@ def test_redirect_cross_host_remove_headers(self) -> None:
141
141
"GET" ,
142
142
f"{ self .base_url } /redirect" ,
143
143
fields = {"target" : f"{ self .base_url_alt } /headers" },
144
- headers = {"Authorization" : "foo" },
144
+ headers = {"Authorization" : "foo" , "Cookie" : "foo=bar" },
145
145
)
146
146
147
147
assert r .status == 200
148
148
149
149
data = r .json ()
150
150
151
151
assert "Authorization" not in data
152
+ assert "Cookie" not in data
152
153
153
154
r = http .request (
154
155
"GET" ,
155
156
f"{ self .base_url } /redirect" ,
156
157
fields = {"target" : f"{ self .base_url_alt } /headers" },
157
- headers = {"authorization" : "foo" },
158
+ headers = {"authorization" : "foo" , "cookie" : "foo=bar" },
158
159
)
159
160
160
161
assert r .status == 200
@@ -163,14 +164,16 @@ def test_redirect_cross_host_remove_headers(self) -> None:
163
164
164
165
assert "authorization" not in data
165
166
assert "Authorization" not in data
167
+ assert "cookie" not in data
168
+ assert "Cookie" not in data
166
169
167
170
def test_redirect_cross_host_no_remove_headers (self ) -> None :
168
171
with PoolManager () as http :
169
172
r = http .request (
170
173
"GET" ,
171
174
f"{ self .base_url } /redirect" ,
172
175
fields = {"target" : f"{ self .base_url_alt } /headers" },
173
- headers = {"Authorization" : "foo" },
176
+ headers = {"Authorization" : "foo" , "Cookie" : "foo=bar" },
174
177
retries = Retry (remove_headers_on_redirect = []),
175
178
)
176
179
@@ -179,14 +182,19 @@ def test_redirect_cross_host_no_remove_headers(self) -> None:
179
182
data = r .json ()
180
183
181
184
assert data ["Authorization" ] == "foo"
185
+ assert data ["Cookie" ] == "foo=bar"
182
186
183
187
def test_redirect_cross_host_set_removed_headers (self ) -> None :
184
188
with PoolManager () as http :
185
189
r = http .request (
186
190
"GET" ,
187
191
f"{ self .base_url } /redirect" ,
188
192
fields = {"target" : f"{ self .base_url_alt } /headers" },
189
- headers = {"X-API-Secret" : "foo" , "Authorization" : "bar" },
193
+ headers = {
194
+ "X-API-Secret" : "foo" ,
195
+ "Authorization" : "bar" ,
196
+ "Cookie" : "foo=bar" ,
197
+ },
190
198
retries = Retry (remove_headers_on_redirect = ["X-API-Secret" ]),
191
199
)
192
200
@@ -196,8 +204,13 @@ def test_redirect_cross_host_set_removed_headers(self) -> None:
196
204
197
205
assert "X-API-Secret" not in data
198
206
assert data ["Authorization" ] == "bar"
207
+ assert data ["Cookie" ] == "foo=bar"
199
208
200
- headers = {"x-api-secret" : "foo" , "authorization" : "bar" }
209
+ headers = {
210
+ "x-api-secret" : "foo" ,
211
+ "authorization" : "bar" ,
212
+ "cookie" : "foo=bar" ,
213
+ }
201
214
r = http .request (
202
215
"GET" ,
203
216
f"{ self .base_url } /redirect" ,
@@ -213,9 +226,14 @@ def test_redirect_cross_host_set_removed_headers(self) -> None:
213
226
assert "x-api-secret" not in data
214
227
assert "X-API-Secret" not in data
215
228
assert data ["Authorization" ] == "bar"
229
+ assert data ["Cookie" ] == "foo=bar"
216
230
217
231
# Ensure the header argument itself is not modified in-place.
218
- assert headers == {"x-api-secret" : "foo" , "authorization" : "bar" }
232
+ assert headers == {
233
+ "x-api-secret" : "foo" ,
234
+ "authorization" : "bar" ,
235
+ "cookie" : "foo=bar" ,
236
+ }
219
237
220
238
def test_redirect_without_preload_releases_connection (self ) -> None :
221
239
with PoolManager (block = True , maxsize = 2 ) as http :
0 commit comments