diff --git a/herepy/routing_api.py b/herepy/routing_api.py index 7586fa9..2f75615 100644 --- a/herepy/routing_api.py +++ b/herepy/routing_api.py @@ -50,12 +50,13 @@ def __get( response_cls, manipulation_key: str = None, keys_for_manipulation: List = None, + headers: Optional[Dict[str, str]] = None, ): url = Utils.build_url(base_url, extra_params=data) if manipulation_key and keys_for_manipulation: for k in keys_for_manipulation: url = url.replace(k, manipulation_key) - response = requests.get(url, timeout=self._timeout) + response = requests.get(url, timeout=self._timeout, headers=headers) json_data = json.loads(response.content.decode("utf8")) if response.status_code == requests.codes.OK: return response_cls.new_from_jsondict(json_data) @@ -492,6 +493,7 @@ def route_v8( RoutingResponseV8, manipulation_key="via", keys_for_manipulation=via_keys, + headers=headers ) return response diff --git a/tests/test_routing_api.py b/tests/test_routing_api.py index ac7323c..204a723 100644 --- a/tests/test_routing_api.py +++ b/tests/test_routing_api.py @@ -1257,3 +1257,20 @@ def test_route_v8_truck_parameter_deprecated(self): destination=[41.9043, -87.9216], truck={"height": ["15000"], "width": ["3000"]}, ) + + @responses.activate + def test_route_v8_headers_in_request(self): + resp = responses.add( + responses.GET, + "https://router.hereapi.com/v8/routes", + "{}", + status=200, + ) + self._api.route_v8( + transport_mode=herepy.RoutingTransportMode.truck, + origin=[41.9798, -87.8801], + destination=[41.9043, -87.9216], + headers={"X-BIP": "BOP"}, + ) + original_request = resp.calls[0].request + self.assertEqual(original_request.headers.get("X-BIP"), "BOP")