From 4544f9cc674f1e5f3ed5d9a5c071c519ebd85012 Mon Sep 17 00:00:00 2001 From: Patrick Huck Date: Fri, 20 Dec 2024 18:40:50 -0800 Subject: [PATCH] use request headers --- mp_api/client/core/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mp_api/client/core/client.py b/mp_api/client/core/client.py index 064c7e87..6c6e52f2 100644 --- a/mp_api/client/core/client.py +++ b/mp_api/client/core/client.py @@ -43,6 +43,11 @@ except ImportError: boto3 = None +try: + import flask +except ImportError: + flask = None + if TYPE_CHECKING: from typing import Any, Callable @@ -984,13 +989,17 @@ def _submit_request_and_process( Returns: Tuple with data and total number of docs in matching the query in the database. """ + headers = None + if flask is not None and flask.has_request_context: + headers = flask.request.headers + try: response = self.session.get( url=url, verify=verify, params=params, timeout=timeout, - headers=self.headers, + headers=headers if headers else self.headers, ) except requests.exceptions.ConnectTimeout: raise MPRestError(