File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 RequestOptions ,
2121 not_given ,
2222)
23- from ._utils import is_given , get_async_library
23+ from ._utils import (
24+ is_given ,
25+ is_mapping_t ,
26+ get_async_library ,
27+ )
2428from ._compat import cached_property
2529from ._models import FinalRequestOptions
2630from ._version import __version__
@@ -158,6 +162,15 @@ def __init__(
158162 except KeyError as exc :
159163 raise ValueError (f"Unknown environment: { environment } " ) from exc
160164
165+ custom_headers_env = os .environ .get ("KERNEL_CUSTOM_HEADERS" )
166+ if custom_headers_env is not None :
167+ parsed : dict [str , str ] = {}
168+ for line in custom_headers_env .split ("\n " ):
169+ colon = line .find (":" )
170+ if colon >= 0 :
171+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
172+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
173+
161174 super ().__init__ (
162175 version = __version__ ,
163176 base_url = base_url ,
@@ -473,6 +486,15 @@ def __init__(
473486 except KeyError as exc :
474487 raise ValueError (f"Unknown environment: { environment } " ) from exc
475488
489+ custom_headers_env = os .environ .get ("KERNEL_CUSTOM_HEADERS" )
490+ if custom_headers_env is not None :
491+ parsed : dict [str , str ] = {}
492+ for line in custom_headers_env .split ("\n " ):
493+ colon = line .find (":" )
494+ if colon >= 0 :
495+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
496+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
497+
476498 super ().__init__ (
477499 version = __version__ ,
478500 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments