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
@@ -122,6 +126,15 @@ def __init__(
122126 except KeyError as exc :
123127 raise ValueError (f"Unknown environment: { environment } " ) from exc
124128
129+ custom_headers_env = os .environ .get ("STUDIO_SDK_CUSTOM_HEADERS" )
130+ if custom_headers_env is not None :
131+ parsed : dict [str , str ] = {}
132+ for line in custom_headers_env .split ("\n " ):
133+ colon = line .find (":" )
134+ if colon >= 0 :
135+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
136+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
137+
125138 super ().__init__ (
126139 version = __version__ ,
127140 base_url = base_url ,
@@ -334,6 +347,15 @@ def __init__(
334347 except KeyError as exc :
335348 raise ValueError (f"Unknown environment: { environment } " ) from exc
336349
350+ custom_headers_env = os .environ .get ("STUDIO_SDK_CUSTOM_HEADERS" )
351+ if custom_headers_env is not None :
352+ parsed : dict [str , str ] = {}
353+ for line in custom_headers_env .split ("\n " ):
354+ colon = line .find (":" )
355+ if colon >= 0 :
356+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
357+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
358+
337359 super ().__init__ (
338360 version = __version__ ,
339361 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments