Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion storage3/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ def __init__(
timeout: int = DEFAULT_TIMEOUT,
verify: bool = True,
proxy: Optional[str] = None,
http_client: Optional[AsyncClient] = None,
) -> None:
headers = {
"User-Agent": f"supabase-py/storage3 v{__version__}",
**headers,
}
self.session = self._create_session(url, headers, timeout, verify, proxy)
self.session = self._create_session(
url, headers, timeout, verify, proxy, http_client
)
super().__init__(self.session)

def _create_session(
Expand All @@ -39,7 +42,13 @@ def _create_session(
timeout: int,
verify: bool = True,
proxy: Optional[str] = None,
http_client: Optional[AsyncClient] = None,
) -> AsyncClient:
if http_client is not None:
http_client.base_url = base_url
http_client.headers = headers
return http_client

return AsyncClient(
base_url=base_url,
headers=headers,
Expand Down
11 changes: 10 additions & 1 deletion storage3/_sync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ def __init__(
timeout: int = DEFAULT_TIMEOUT,
verify: bool = True,
proxy: Optional[str] = None,
http_client: Optional[SyncClient] = None,
) -> None:
headers = {
"User-Agent": f"supabase-py/storage3 v{__version__}",
**headers,
}
self.session = self._create_session(url, headers, timeout, verify, proxy)
self.session = self._create_session(
url, headers, timeout, verify, proxy, http_client
)
super().__init__(self.session)

def _create_session(
Expand All @@ -39,7 +42,13 @@ def _create_session(
timeout: int,
verify: bool = True,
proxy: Optional[str] = None,
http_client: Optional[SyncClient] = None,
) -> SyncClient:
if http_client is not None:
http_client.base_url = base_url
http_client.headers = headers
return http_client

return SyncClient(
base_url=base_url,
headers=headers,
Expand Down