From 7c8cf804ac45744c61cb836fd2a8c6043b4444e2 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 23 Sep 2024 14:58:57 -0300 Subject: [PATCH 1/6] feat: Proxy support --- storage3/_async/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage3/_async/client.py b/storage3/_async/client.py index d9cbc7d..6af6209 100644 --- a/storage3/_async/client.py +++ b/storage3/_async/client.py @@ -21,21 +21,23 @@ def __init__( headers: dict[str, str], timeout: int = DEFAULT_TIMEOUT, verify: bool = True, + proxy: str | None = None, ) -> None: headers = { "User-Agent": f"supabase-py/storage3 v{__version__}", **headers, } - self.session = self._create_session(url, headers, timeout, verify) + self.session = self._create_session(url, headers, timeout, verify, proxy) super().__init__(self.session) def _create_session( - self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True + self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: str | None = None, ) -> AsyncClient: return AsyncClient( base_url=base_url, headers=headers, timeout=timeout, + proxy=proxy, verify=bool(verify), follow_redirects=True, http2=True, From d86ffbe6d9980a2c1eafe0399e86486d01cd3e40 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 23 Sep 2024 14:59:03 -0300 Subject: [PATCH 2/6] feat: Proxy support --- storage3/_sync/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage3/_sync/client.py b/storage3/_sync/client.py index ba62ceb..c0834c2 100644 --- a/storage3/_sync/client.py +++ b/storage3/_sync/client.py @@ -21,21 +21,23 @@ def __init__( headers: dict[str, str], timeout: int = DEFAULT_TIMEOUT, verify: bool = True, + proxy: str | None = None, ) -> None: headers = { "User-Agent": f"supabase-py/storage3 v{__version__}", **headers, } - self.session = self._create_session(url, headers, timeout, verify) + self.session = self._create_session(url, headers, timeout, verify, proxy) super().__init__(self.session) def _create_session( - self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True + self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: str | None = None, ) -> SyncClient: return SyncClient( base_url=base_url, headers=headers, timeout=timeout, + proxy=proxy, verify=bool(verify), follow_redirects=True, http2=True, From 1b3a7f3108a55bb5bd3d5d7061380214cbf58c70 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Tue, 24 Sep 2024 10:40:14 -0300 Subject: [PATCH 3/6] feat: Proxy support --- storage3/_async/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage3/_async/client.py b/storage3/_async/client.py index 6af6209..1d8e94d 100644 --- a/storage3/_async/client.py +++ b/storage3/_async/client.py @@ -1,4 +1,5 @@ from __future__ import annotations +from typing import Optional from storage3.constants import DEFAULT_TIMEOUT @@ -21,7 +22,7 @@ def __init__( headers: dict[str, str], timeout: int = DEFAULT_TIMEOUT, verify: bool = True, - proxy: str | None = None, + proxy: Optional[str] = None, ) -> None: headers = { "User-Agent": f"supabase-py/storage3 v{__version__}", @@ -31,7 +32,7 @@ def __init__( super().__init__(self.session) def _create_session( - self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: str | None = None, + self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: Optional[str] = None, ) -> AsyncClient: return AsyncClient( base_url=base_url, From f9c9bcae29d3cb22118b541254f86ba0fba3eed9 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Tue, 24 Sep 2024 10:40:21 -0300 Subject: [PATCH 4/6] feat: Proxy support --- storage3/_sync/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage3/_sync/client.py b/storage3/_sync/client.py index c0834c2..504f79c 100644 --- a/storage3/_sync/client.py +++ b/storage3/_sync/client.py @@ -1,4 +1,5 @@ from __future__ import annotations +from typing import Optional from storage3.constants import DEFAULT_TIMEOUT @@ -21,7 +22,7 @@ def __init__( headers: dict[str, str], timeout: int = DEFAULT_TIMEOUT, verify: bool = True, - proxy: str | None = None, + proxy: Optional[str] = None, ) -> None: headers = { "User-Agent": f"supabase-py/storage3 v{__version__}", @@ -31,7 +32,7 @@ def __init__( super().__init__(self.session) def _create_session( - self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: str | None = None, + self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: Optional[str] = None, ) -> SyncClient: return SyncClient( base_url=base_url, From 9cfb45ed38683cc4485db130148d3071f4b29d3b Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Tue, 24 Sep 2024 10:52:53 -0300 Subject: [PATCH 5/6] feat: Proxy support --- storage3/_async/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/storage3/_async/client.py b/storage3/_async/client.py index 1d8e94d..95852a0 100644 --- a/storage3/_async/client.py +++ b/storage3/_async/client.py @@ -1,4 +1,5 @@ from __future__ import annotations + from typing import Optional from storage3.constants import DEFAULT_TIMEOUT @@ -32,7 +33,12 @@ def __init__( super().__init__(self.session) def _create_session( - self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: Optional[str] = None, + self, + base_url: str, + headers: dict[str, str], + timeout: int, + verify: bool = True, + proxy: Optional[str] = None, ) -> AsyncClient: return AsyncClient( base_url=base_url, From 25fdb673504c6ff936f96346942ac5f8dce57b67 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Tue, 24 Sep 2024 10:52:58 -0300 Subject: [PATCH 6/6] feat: Proxy support --- storage3/_sync/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/storage3/_sync/client.py b/storage3/_sync/client.py index 504f79c..d2a2e29 100644 --- a/storage3/_sync/client.py +++ b/storage3/_sync/client.py @@ -1,4 +1,5 @@ from __future__ import annotations + from typing import Optional from storage3.constants import DEFAULT_TIMEOUT @@ -32,7 +33,12 @@ def __init__( super().__init__(self.session) def _create_session( - self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True, proxy: Optional[str] = None, + self, + base_url: str, + headers: dict[str, str], + timeout: int, + verify: bool = True, + proxy: Optional[str] = None, ) -> SyncClient: return SyncClient( base_url=base_url,