I have a socks5 proxy used in the system and it's not supported by httpx. all_proxy environmental variable points to socks5 proxy, therefore httpx.get('https://httpbin.org/get') call results in an error (Unknown proxy for URL).
To bypass that I specify trust_env=False like this httpx.get('https://httpbin.org/get', trust_env=False), but still get the same error.
I looked up the request method implementation in the api.py and apparently when the Client instance is created none of the request method parameters are being passed to the constructor.
https://github.com/encode/httpx/blob/master/httpx/api.py#L80
Therefore inside the BaseClient's __init__ method trust_env has the default value (True). And accordingly to this value tries to deduce the proxy settings from the environment variable, which causes the error.
It would be great if you passed the trust_env value to __init__ when creating Client's instance.
Good catch, yup. I think we should only pass trust_env to the Client in that case, and not bother including it on the request (it will just default to the client value).
Stylistically I'd be tempted to do the same for timeout, cert, verify too, which are more typically per-client than per-request.
Closed via #544
Most helpful comment
Good catch, yup. I think we should only pass
trust_envto the Client in that case, and not bother including it on the request (it will just default to the client value).Stylistically I'd be tempted to do the same for
timeout,cert,verifytoo, which are more typically per-client than per-request.