diff --git a/herepy/routing_api.py b/herepy/routing_api.py index 4068c3d..683f0ec 100644 --- a/herepy/routing_api.py +++ b/herepy/routing_api.py @@ -49,12 +49,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) @@ -480,6 +481,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 76b1e5f..c7e882b 100644 --- a/tests/test_routing_api.py +++ b/tests/test_routing_api.py @@ -1234,3 +1234,20 @@ def test_route_v8_url_parameters_multiple(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")