This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author CrazyBoyFeng
Recipients CrazyBoyFeng, NateScarlet, benrg, chrisxiao, corona10, kotori, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-06-07.19:10:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
We should have no problem with how to parse HTTP proxy and HTTPS proxy. But I recently discovered an additional problem when using `requests`, that is, how to parse the SOCKS proxy correctly.

I investigated the parsing of some commonly used software:
`curl` will try to read the `all_proxy` variable first, if not, then read the two system environment variables `http_proxy` and `https_proxy`.
Only these two environment variables related to proxy exist in most Linux distributions.
The following formats are valid for `curl`:
export http_proxy=socks4h://
export https_proxy=socks5://
The `h` in `socks4h` means doing DNS query on the proxy server.

`requests` also follows this format.
If you want to use the socks proxy in `requests[socks]`, you need to specify the proxies parameter:

Since it is customary to resolve SOCKS proxies in this way, I think CPython can consider doing the same with Windows registry.

In previous versions, CPython parsed the SOCKS proxy in the Windows registry `socks=localhost:8080` as:
I think it can be changed to
proxies['http']=proxies['http'] or'socks4://localhost:8080'
proxies['https']=proxies['http'] or'socks4://localhost:8080'
The use of `or` is to prevent the existing HTTP and HTTPS proxy settings from being overwritten.  
I tried it on my Win10 PC. When I set up HTTP and SOCKS proxies at the same time, IE and Edge will use HTTP proxy.  
The reason using `socks4` instead of `socks4h` or `socks5` is that, when I change system proxy setting to a remote SOCKS proxy, I found that IE and Edge do not query DNS from the proxy but from local DNS polluted by the ISP. And if the running socks proxy version is SOCKS5, it will output errors of `unsupported socks version 0x4`. So Windows only supports the SOCKS proxy `socks4://`.  
It's a pity that we don't know the code of Windows, and I can't prove it with the codes.  
`proxies['socks']` is reserved for backward compatibility.

If you have any comments or suggestions, please let me know.
Date User Action Args
2021-06-07 19:10:54CrazyBoyFengsetrecipients: + CrazyBoyFeng, paul.moore, tim.golden, benrg, zach.ware, steve.dower, corona10, chrisxiao, kotori, NateScarlet
2021-06-07 19:10:54CrazyBoyFengsetmessageid: <>
2021-06-07 19:10:54CrazyBoyFenglinkissue42627 messages
2021-06-07 19:10:54CrazyBoyFengcreate