Skip to content

Commit

Permalink
fix: add "verify" flag to the creation of client
Browse files Browse the repository at this point in the history
  • Loading branch information
juancarlospaco authored Jun 4, 2024
1 parent ed5ed18 commit 9ad75b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions storage3/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ class AsyncStorageClient(AsyncStorageBucketAPI):
"""Manage storage buckets and files."""

def __init__(
self, url: str, headers: dict[str, str], timeout: int = DEFAULT_TIMEOUT
self,
url: str,
headers: dict[str, str],
timeout: int = DEFAULT_TIMEOUT,
verify: bool = True,
) -> None:
headers = {
"User-Agent": f"supabase-py/storage3 v{__version__}",
**headers,
}
self.session = self._create_session(url, headers, timeout)
self.session = self._create_session(url, headers, timeout, verify)
super().__init__(self.session)

def _create_session(
self, base_url: str, headers: dict[str, str], timeout: int
self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True
) -> AsyncClient:
return AsyncClient(base_url=base_url, headers=headers, timeout=timeout)
return AsyncClient(
base_url=base_url, headers=headers, timeout=timeout, verify=bool(verify)
)

async def __aenter__(self) -> AsyncStorageClient:
return self
Expand Down
14 changes: 10 additions & 4 deletions storage3/_sync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ class SyncStorageClient(SyncStorageBucketAPI):
"""Manage storage buckets and files."""

def __init__(
self, url: str, headers: dict[str, str], timeout: int = DEFAULT_TIMEOUT
self,
url: str,
headers: dict[str, str],
timeout: int = DEFAULT_TIMEOUT,
verify: bool = True,
) -> None:
headers = {
"User-Agent": f"supabase-py/storage3 v{__version__}",
**headers,
}
self.session = self._create_session(url, headers, timeout)
self.session = self._create_session(url, headers, timeout, verify)
super().__init__(self.session)

def _create_session(
self, base_url: str, headers: dict[str, str], timeout: int
self, base_url: str, headers: dict[str, str], timeout: int, verify: bool = True
) -> SyncClient:
return SyncClient(base_url=base_url, headers=headers, timeout=timeout)
return SyncClient(
base_url=base_url, headers=headers, timeout=timeout, verify=bool(verify)
)

def __enter__(self) -> SyncStorageClient:
return self
Expand Down

0 comments on commit 9ad75b0

Please sign in to comment.