-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Clean rebased version of https-proxy #170
Conversation
Is there anything I can do to help keep this moving along, @shazow? I appreciate you have lots of pressure on your time, so if there's anything you'd like me to do please say. =) |
Hm so what's the status of this? Is it ready to be considered for merging again? I'm still seeing a bunch of Anyone familiar with software copyright/licenses have insight on whether it's a problem to introduce separately licensed submodules into the main codebase? (dummyserver/proxy.py) Should we try to consolidate the licenses? |
The only Personally I think all proxy auth should be handled in the URL, with maybe an alternate option of passing it into the How is basic auth handled normally? I see a |
urllib3's level of abstraction does not hide headers from the user. The user is responsible for making headers, such as by using |
This is exactly the same thing than the vendored libraries in packages or I am missing something?!
The first TODO is proposing an optimization in a backward compatibility branch, this can be ignored/dropped. Basic proxy authorization looks pretty simple (from urllib2):
But I guess we should have a proper way to test this? |
@shazow Please please please can this be merged? This makes requests work with https proxies, and doesn't break anything that we could detect. But since no version of requests or urllib3 on pypi carries this patchset, we have to vendor requests+urllib3 with it applied. |
@@ -171,12 +177,20 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods): | |||
:param headers: | |||
Headers to include with all requests, unless other headers are given | |||
explicitly. | |||
|
|||
:param proxy: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these params are "internal", should we prefix them with an underscore? _proxy
and _proxy_headers
.
Honestly I'm not a huge fan of having them here, but I can't think of a better solution right now.
Hey @kislyuk and fellow Andrey. My apologies, this has been a very long-lived issue and has been a lot of work to get right. We're almost there, though. This branch looks very close but it may still be some time until it's merged and published. If you'd like to help, more reviews of this code would be appreciated, and any additional tests you can add are always helpful too. Alternatively, you can campaign for @kennethreitz to maintain a vendored version of urllib3 with this merged in, but that might be a hard sell. :) @schlamar Thanks for all of your work so far! Could you also rebase this branch on the latest master when you have a chance? |
Some failing tests on Windows, someone any idea: https://gist.github.com/schlamar/03b01c41bab64ed02bbf |
I have updated my automatic test script with the latest rebased versions of urllib3 and requests. Everyone with a proxy environment should give it a try: https://gist.github.com/schlamar/5080598 |
Things to address (AFAIS). These are links to specific comments:
Edit: Ping @shazow Anything else? |
I can try taking a look at some of the windows stuff this evening if no-one gets around to it before me. |
The test is failing, because the response returned by the dummy_server is missing the Changing the status of the response returned from See #205. |
Ah, I guess this is only an issue for Tornado >= 3. Should fix my test dependencies... |
@schlamar Your list sounds about right. Added it as a check list to the bug description. |
@shazow Last TODO is fixed. (failing test) |
#208 fixes the bug about SSL not being available. (second TODO) |
Just +1'ing in order to track the issue. Sounds like this has been going for a long time, well done to everyone involved, keep your spirits up, and thanks for all the hard work! |
New rebase against master. @stanvit I revoked your write access because I'm back from vacation. Please send your changes as pull request against my proxy-rebase-fix branch. I often do history rewrites so this would be nasty if we two write in parallel to the same branch (I already had to clean up your merge commit). |
Updated the todo list. @shazow Last two points are waiting for your answer :) |
@stanvit I stripped out this commit in favor of this one. I assume they have the same goal, right? |
I'm satisfied. :) Is this it for everyone? |
Ship it 👍 |
@@ -145,7 +149,10 @@ def urlopen(self, method, url, redirect=True, **kw): | |||
if 'headers' not in kw: | |||
kw['headers'] = self.headers | |||
|
|||
response = conn.urlopen(method, u.request_uri, **kw) | |||
if self.proxy is not None and u.scheme == "http": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining this condition?
Also would it be better to just set url = u.request_uri
rather than fork the whole line?
Couple of minor style requests, otherwise ready to merge. :) |
You guys are amazing, thank you all. ✨ |
🏁 SHIP IT BABY! 🏁 - Great effort all |
Thank you everybody for pushing this! |
Is it possible this isn't passing auth details along? After applying the above patch I am getting: Before the patch I was getting: |
Yes, proxy auth is still missing. |
Is there anyway I can make this work, by passing in the headers manually or something? Or is it simply not supported right now? |
This should work I guess :) But please create a new ticket to request proxy auth support. |
Proxy authentication is working for me on the low level: the >>> from urllib3.poolmanager import ProxyManager
>>> goodauth = ProxyManager('http://localhost:3128', proxy_headers={'Proxy-Authorization': 'Basic dGVzdDp0ZXN0'})
>>> goodauth.request('GET', 'https://httpbin.org/get').status
200
>>> goodauth.request('GET', 'http://httpbin.org/get').status
200
>>> badauth = ProxyManager('http://localhost:3128', proxy_headers={'Proxy-Authorization': 'Basic garbage'})
>>> badauth.request('GET', 'https://httpbin.org/get').status
Traceback (most recent call last):
...
urllib3.exceptions.ProxyError: Cannot connect to proxy. Socket error: Tunnel connection failed: 407 Proxy Authentication Required.
>>> badauth.request('GET', 'http://httpbin.org/get').status
407 |
Would be awesome to get some examples like that into the docs, if anyone wants to do a PR. :) |
This is a cleaned up version of #139 rebased against current master.
Current todo:
All discussions in the diff
Other