File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55from typing import Dict
66
7- from e2b .connection_config import ConnectionConfig
7+ from e2b .connection_config import ConnectionConfig , _resolve_proxy
88from e2b .api import limits , AsyncApiClient
99
1010
@@ -45,7 +45,7 @@ def get_transport(config: ConnectionConfig) -> AsyncTransportWithLogger:
4545
4646 transport = AsyncTransportWithLogger (
4747 limits = limits ,
48- proxy = config .proxy ,
48+ proxy = _resolve_proxy ( config .proxy ) ,
4949 )
5050 AsyncTransportWithLogger ._instances [loop_id ] = transport
5151 return transport
Original file line number Diff line number Diff line change 44import logging
55
66from e2b .api import ApiClient , limits
7- from e2b .connection_config import ConnectionConfig
7+ from e2b .connection_config import ConnectionConfig , _resolve_proxy
88
99logger = logging .getLogger (__name__ )
1010
@@ -44,7 +44,7 @@ def get_transport(config: ConnectionConfig) -> TransportWithLogger:
4444
4545 transport = TransportWithLogger (
4646 limits = limits ,
47- proxy = config .proxy ,
47+ proxy = _resolve_proxy ( config .proxy ) ,
4848 )
4949 TransportWithLogger .singleton = transport
5050 return transport
Original file line number Diff line number Diff line change @@ -208,6 +208,25 @@ def sandbox_headers(self):
208208 }
209209
210210
211+ def _resolve_proxy (proxy : Optional [ProxyTypes ]) -> Optional [ProxyTypes ]:
212+ """
213+ Resolve the proxy to use for a request.
214+ If an explicit proxy is provided, use it. Otherwise, fall back to
215+ standard environment variables (HTTPS_PROXY, HTTP_PROXY, ALL_PROXY).
216+ """
217+ if proxy is not None :
218+ return proxy
219+
220+ return (
221+ os .environ .get ("https_proxy" )
222+ or os .environ .get ("HTTPS_PROXY" )
223+ or os .environ .get ("http_proxy" )
224+ or os .environ .get ("HTTP_PROXY" )
225+ or os .environ .get ("all_proxy" )
226+ or os .environ .get ("ALL_PROXY" )
227+ )
228+
229+
211230Username = str
212231"""
213232User used for the operation in the sandbox.
Original file line number Diff line number Diff line change 88from e2b .api .metadata import default_headers
99from e2b .exceptions import AuthenticationException
1010from e2b .volume .client .client import AuthenticatedClient as AsyncVolumeApiClient
11+ from e2b .connection_config import _resolve_proxy
1112from e2b .volume .connection_config import VolumeConnectionConfig
1213
1314logger = logging .getLogger (__name__ )
@@ -63,7 +64,7 @@ def get_transport(config: VolumeConnectionConfig) -> AsyncTransportWithLogger:
6364
6465 transport = AsyncTransportWithLogger (
6566 limits = limits ,
66- proxy = config .proxy ,
67+ proxy = _resolve_proxy ( config .proxy ) ,
6768 )
6869 AsyncTransportWithLogger .singleton = transport
6970 return transport
Original file line number Diff line number Diff line change 88from e2b .api .metadata import default_headers
99from e2b .exceptions import AuthenticationException
1010from e2b .volume .client .client import AuthenticatedClient as VolumeApiClient
11+ from e2b .connection_config import _resolve_proxy
1112from e2b .volume .connection_config import VolumeConnectionConfig
1213
1314logger = logging .getLogger (__name__ )
@@ -63,7 +64,7 @@ def get_transport(config: VolumeConnectionConfig) -> TransportWithLogger:
6364
6465 transport = TransportWithLogger (
6566 limits = limits ,
66- proxy = config .proxy ,
67+ proxy = _resolve_proxy ( config .proxy ) ,
6768 )
6869 TransportWithLogger .singleton = transport
6970 return transport
You can’t perform that action at this time.
0 commit comments