Protocol not parsed when setting proxy config from env vars #3070
Conversation
I just realized this PR is a dupe of #2562. I would still pull this one in though since it includes unit tests. |
+1, @jonathanfoster was just considering creating PR myself until I came across yours. Adding protocol supports will provide parity with deprecated requests project. Any idea when this will be merged? |
Looks like @chinesedfan removed the work in progress label a few days ago. I’m not sure what the workflow is like, but this makes me think it won’t make it into the next release. @chinesedfan or @jasonsaayman, can you guys provide an update? Anything else we need to do to ship this PR? |
I think it will make it into the next release, I am starting to collect pull requests for 0.21 should get here soon. Thanks |
@jasonsaayman Looks like this one didn't make it into 0.21. Anything I can do to help get it in 0.22? This PR fixes a huge pain point for anyone using axios behind a corporate proxy. |
This looks good to me, has tests, and does not seem to break backward compatibility. |
@chinesedfan can you have a look let me know if we can merge? |
Looks good to me, except for a few suggestions. |
It looks like all the requested changes have been completed @chinesedfan. Bumping this thread as a follow up. |
This PR resolves the issue when setting proxy config from env vars, the proxy config protocol is not set based on the env var URL. This causes all proxy server connections to use HTTP and results in invalid request errors.
If you set HTTPS_PROXY to an HTTPS URL...
export HTTPS_PROXY=https://localhost:8080
then the proxy config will be set without protocol, which is used later on to initiate the proxy connection.
The proxy config should include protocol when parsing from env vars.
To reproduce this issue, create a local HTTPS proxy with mitmproxy and set
HTTPS_PROXY
to https://localhost:8080. mitmproxy will respond with a 400 and the error messageHTTP protocol error in client request: Invalid request scheme: https
.