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
@@ -144,6 +148,15 @@ def __init__(
144148 except KeyError as exc :
145149 raise ValueError (f"Unknown environment: { environment } " ) from exc
146150
151+ custom_headers_env = os .environ .get ("KERNEL_CUSTOM_HEADERS" )
152+ if custom_headers_env is not None :
153+ parsed : dict [str , str ] = {}
154+ for line in custom_headers_env .split ("\n " ):
155+ colon = line .find (":" )
156+ if colon >= 0 :
157+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
158+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
159+
147160 super ().__init__ (
148161 version = __version__ ,
149162 base_url = base_url ,
@@ -421,6 +434,15 @@ def __init__(
421434 except KeyError as exc :
422435 raise ValueError (f"Unknown environment: { environment } " ) from exc
423436
437+ custom_headers_env = os .environ .get ("KERNEL_CUSTOM_HEADERS" )
438+ if custom_headers_env is not None :
439+ parsed : dict [str , str ] = {}
440+ for line in custom_headers_env .split ("\n " ):
441+ colon = line .find (":" )
442+ if colon >= 0 :
443+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
444+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
445+
424446 super ().__init__ (
425447 version = __version__ ,
426448 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments