-
-
Notifications
You must be signed in to change notification settings - Fork 857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should we support bare hostnames in ALL_PROXY
,HTTP_PROXY
, HTTPS_PROXY
?
#1082
Comments
Hi! I assume cURL and other tools also allow proxy URLs with explicit schemes, that is If so then I believe switching your env var to such a form should be the way to go. I don't think we want to allow no-scheme URLs in general, because that would require an arbitrary decision on "what is the default scheme?", and it's not clear which of HTTP or HTTPS would be best. Allowing no scheme URLs for proxies alone brings more complexity, which is something we're trying to avoid as much as possible. So a solution of hinting users that "yes, you should use an explicit scheme" is probably best. Now, one thing we could do to improve the debugging experience is show the faulty URL in the error message. (I think there's also room for improving the debugging material for "how proxies are set up", for instance to be able to trace whether env vars were used and how. But we can probably advise on this later.) |
yes, other tools allow explicit schemes. and if user not add scheme in their url, they may add a default I think this is indeed a user experience problem, because the environment proxy setting may serveral days ago, user may forget it. |
FYI, after the drop of |
@j178 I wouldn't mind making sure we've got a decent UX around handling that case. |
@tomchristie Both.
|
Right, not entirely clear if we should aim to be lenient to this, or if we should just make sure the error is as clear as possible. I'd be interested to know how |
Another useful data point here would be - what does |
ALL_PROXY
,HTTP_PROXY
, HTTPS_PROXY
environment variables?
ALL_PROXY
,HTTP_PROXY
, HTTPS_PROXY
environment variables?ALL_PROXY
,HTTP_PROXY
, HTTPS_PROXY
?
I did some tests:
# without proxy, I cannot connect to google
$ curl --connect-timeout 5 google.com
curl: (28) Connection timed out after 5000 milliseconds
# bare hostname proxy works
$ all_proxy=127.0.0.1:7890 curl --connect-timeout 5 google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
$ all_proxy=127.0.0.1:7890 python -c "import requests; print(requests.get('http://google.com'))"
<Response [200]>
|
Okay, in that case we should follow the same behaviour. We'll want something like... if not url.scheme:
url = url.copy_with(scheme="http") |
Checklist
master
.Describe the bug
I am a new user for httpx, and I just install it, then try to run it in python REPL.
I type
httpx.get('https://www.github.com')
and then got the "No scheme included in URL".So I try to debug it, and finally I found that because I set the
export ALL_PROXY=127.0.0.1:7890
in the shell, the proxy does not have a scheme.This proxy set is correct for when I use curl、brew and many other programe, So it should also work fun in httpx?
for any other reason httpx must have the scheme, I think it should prompt "a proxy set error" at least.
Debugging material
Environment
127.0.0.1:7890
The text was updated successfully, but these errors were encountered: