File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,13 @@ def __get(
49
49
response_cls ,
50
50
manipulation_key : str = None ,
51
51
keys_for_manipulation : List = None ,
52
+ headers : Optional [Dict [str , str ]] = None ,
52
53
):
53
54
url = Utils .build_url (base_url , extra_params = data )
54
55
if manipulation_key and keys_for_manipulation :
55
56
for k in keys_for_manipulation :
56
57
url = url .replace (k , manipulation_key )
57
- response = requests .get (url , timeout = self ._timeout )
58
+ response = requests .get (url , timeout = self ._timeout , headers = headers )
58
59
json_data = json .loads (response .content .decode ("utf8" ))
59
60
if response .status_code == requests .codes .OK :
60
61
return response_cls .new_from_jsondict (json_data )
@@ -480,6 +481,7 @@ def route_v8(
480
481
RoutingResponseV8 ,
481
482
manipulation_key = "via" ,
482
483
keys_for_manipulation = via_keys ,
484
+ headers = headers
483
485
)
484
486
return response
485
487
Original file line number Diff line number Diff line change @@ -1234,3 +1234,20 @@ def test_route_v8_url_parameters_multiple(self):
1234
1234
destination = [41.9043 , - 87.9216 ],
1235
1235
truck = {"height" : ["15000" ], "width" : ["3000" ]}
1236
1236
)
1237
+
1238
+ @responses .activate
1239
+ def test_route_v8_headers_in_request (self ):
1240
+ resp = responses .add (
1241
+ responses .GET ,
1242
+ "https://router.hereapi.com/v8/routes" ,
1243
+ "{}" ,
1244
+ status = 200 ,
1245
+ )
1246
+ self ._api .route_v8 (
1247
+ transport_mode = herepy .RoutingTransportMode .truck ,
1248
+ origin = [41.9798 , - 87.8801 ],
1249
+ destination = [41.9043 , - 87.9216 ],
1250
+ headers = {"X-BIP" : "BOP" },
1251
+ )
1252
+ original_request = resp .calls [0 ].request
1253
+ self .assertEqual (original_request .headers .get ("X-BIP" ), "BOP" )
You can’t perform that action at this time.
0 commit comments