Skip to content

Commit

Permalink
use request headers
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Dec 21, 2024
1 parent 534266c commit 4544f9c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mp_api/client/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
except ImportError:
boto3 = None

try:
import flask
except ImportError:
flask = None

if TYPE_CHECKING:
from typing import Any, Callable

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4544f9c

Please sign in to comment.