mirror of
https://github.com/arabianq/viking-file-python.git
synced 2026-07-25 21:56:58 +00:00
feat: trust_env=True for ClientSession
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ BASE_URL = "https://vikingfile.com/api/"
|
||||
@asynccontextmanager
|
||||
async def _get_session(session: ClientSession | None) -> AsyncGenerator[ClientSession, None]:
|
||||
close_session = session is None
|
||||
session = session or ClientSession()
|
||||
session = session or ClientSession(trust_env=True)
|
||||
try:
|
||||
yield session
|
||||
finally:
|
||||
|
||||
@@ -10,7 +10,7 @@ from viking_file.clients.client_async import AsyncVikingClient
|
||||
class VikingClient(AsyncVikingClient):
|
||||
def __init__(self, user_hash: str = "", api_timeout: int = 10):
|
||||
self._loop = asyncio.new_event_loop()
|
||||
session = ClientSession(loop=self._loop)
|
||||
session = ClientSession(loop=self._loop, trust_env=True)
|
||||
super().__init__(user_hash, api_timeout, session)
|
||||
|
||||
def __enter__(self):
|
||||
|
||||
@@ -33,7 +33,7 @@ class AsyncVikingClient:
|
||||
self.hash = user_hash
|
||||
self.timeout = api_timeout
|
||||
self._close_session = _session is None
|
||||
self._session = _session or ClientSession()
|
||||
self._session = _session or ClientSession(trust_env=True)
|
||||
|
||||
atexit.register(self._cleanup)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user