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 ._version import __version__
2630from ._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.openlayer.com/v1"
97101
102+ custom_headers_env = os .environ .get ("OPENLAYER_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 ,
@@ -306,6 +319,15 @@ def __init__(
306319 if base_url is None :
307320 base_url = f"https://api.openlayer.com/v1"
308321
322+ custom_headers_env = os .environ .get ("OPENLAYER_CUSTOM_HEADERS" )
323+ if custom_headers_env is not None :
324+ parsed : dict [str , str ] = {}
325+ for line in custom_headers_env .split ("\n " ):
326+ colon = line .find (":" )
327+ if colon >= 0 :
328+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
329+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
330+
309331 super ().__init__ (
310332 version = __version__ ,
311333 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments