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
@@ -94,6 +98,15 @@ def __init__(
9498 if base_url is None :
9599 base_url = f"https://api.zeroentropy.dev/v1"
96100
101+ custom_headers_env = os .environ .get ("ZEROENTROPY_CUSTOM_HEADERS" )
102+ if custom_headers_env is not None :
103+ parsed : dict [str , str ] = {}
104+ for line in custom_headers_env .split ("\n " ):
105+ colon = line .find (":" )
106+ if colon >= 0 :
107+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
108+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
109+
97110 super ().__init__ (
98111 version = __version__ ,
99112 base_url = base_url ,
@@ -292,6 +305,15 @@ def __init__(
292305 if base_url is None :
293306 base_url = f"https://api.zeroentropy.dev/v1"
294307
308+ custom_headers_env = os .environ .get ("ZEROENTROPY_CUSTOM_HEADERS" )
309+ if custom_headers_env is not None :
310+ parsed : dict [str , str ] = {}
311+ for line in custom_headers_env .split ("\n " ):
312+ colon = line .find (":" )
313+ if colon >= 0 :
314+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
315+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
316+
295317 super ().__init__ (
296318 version = __version__ ,
297319 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments