File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 RequestOptions ,
2020 not_given ,
2121)
22- from ._utils import is_given , get_async_library
22+ from ._utils import (
23+ is_given ,
24+ is_mapping_t ,
25+ get_async_library ,
26+ )
2327from ._compat import cached_property
2428from ._version import __version__
2529from ._streaming import Stream as Stream , AsyncStream as AsyncStream
@@ -95,6 +99,15 @@ def __init__(
9599 if base_url is None :
96100 base_url = f"https://api.browserbase.com"
97101
102+ custom_headers_env = os .environ .get ("BROWSERBASE_CUSTOM_HEADERS" )
103+ if custom_headers_env is not None :
104+ parsed : dict [str , str ] = {}
105+ for line in custom_headers_env .split ("\n " ):
106+ colon = line .find (":" )
107+ if colon >= 0 :
108+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
109+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
110+
98111 super ().__init__ (
99112 version = __version__ ,
100113 base_url = base_url ,
@@ -299,6 +312,15 @@ def __init__(
299312 if base_url is None :
300313 base_url = f"https://api.browserbase.com"
301314
315+ custom_headers_env = os .environ .get ("BROWSERBASE_CUSTOM_HEADERS" )
316+ if custom_headers_env is not None :
317+ parsed : dict [str , str ] = {}
318+ for line in custom_headers_env .split ("\n " ):
319+ colon = line .find (":" )
320+ if colon >= 0 :
321+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
322+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
323+
302324 super ().__init__ (
303325 version = __version__ ,
304326 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments