ITADN

Environment variable config for `trust_env`

#12556Closedwhitead 创建于 2026-05-16
enhancement
W
whiteadcommented
### Is your feature request related to a problem? We require our code to use a proxy. To get aiohttp to use our proxy correctly, I need to construct clients with `trust_env=True`. This creates an issue for developers of our library to always remember this flag, which is not obvious. It would be nice to have an environment variable for this configuration. ### Describe the solution you'd like ```sh AIOHTTP_SAFE_ENV_DEFAULT=TRUE ``` ### Describe alternatives you've considered This monkey patching of the initializer ```py _original_init = aiohttp.ClientSession.__init__ def _patched_init(self, *args, **kwargs): kwargs.setdefault("trust_env", True) _original_init(self, *args, **kwargs) aiohttp.ClientSession.__init__ = _patched_init ``` ### Related component Client ### Additional context _No response_ ### Code of Conduct - [x] I agree to follow the aio-libs Code of Conduct
关闭于 2026-05-16 1 条评论