diff --git a/sources/rest_api/client.py b/sources/rest_api/client.py index 07fec8617..6fb237445 100644 --- a/sources/rest_api/client.py +++ b/sources/rest_api/client.py @@ -2,9 +2,11 @@ import copy from requests.auth import AuthBase +from requests import Session as BaseSession + from dlt.common import logger -from dlt.sources.helpers import requests +from dlt.sources.helpers.requests import client from .paginators import BasePaginator, UnspecifiedPaginator from .detector import create_paginator @@ -29,10 +31,12 @@ def __init__( headers: Optional[Dict[str, str]] = None, auth: Optional[AuthBase] = None, paginator: Optional[BasePaginator] = None, + session: BaseSession = None ) -> None: self.base_url = base_url self.headers = headers self.auth = auth + self.session = session or client.session self.paginator = paginator if paginator else UnspecifiedPaginator() def make_request(self, path="", method="get", params=None, json=None): @@ -46,7 +50,7 @@ def make_request(self, path="", method="get", params=None, json=None): f"json={json}" ) - response = requests.request( + response = self.session.request( method=method, url=url, headers=self.headers,