-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Wrong results using proxies and HTTPS #1359
Comments
Requests' current implementation of proxying is lacking when it comes to HTTPS, and right now there isn't a lot we can do about it. We're waiting on urllib3/urllib3#170 (which was urllib3/urllib3#139, which was intended to resolve urllib3/urllib3#50, just in case you wanted to know how long this has been going on) to implement the HTTP CONNECT verb in urllib3. At the moment, if you try to proxy an HTTPS connection through an HTTP proxy, everything is just...weird. I've seen a wide variety of behaviour. In the best case, the proxy will see that you requested an HTTPS connection and will create such a connection between itself and the endpoint, then strip the SSL and send the data to you over HTTP, but realistically that rarely happens. Thanks for reporting this bug, and I'm sorry there isn't more we can do right now. You're one of a fairly long list of people who is waiting on this, and I promise that it is very, very high up our list of priorities. |
@astratto Can you try: urllib3/urllib3#170 (comment) |
@schlamar I've just tried and it works! Great! import sys
sys.path.insert(0, 'requests-new-urllib3-api/requests/packages/')
sys.path.insert(0, 'requests-new-urllib3-api')
import requests
rs = requests.session()
proxies = { 'https': "http://localhost:3128" }
res = rs.request("get",
... "https://api.bitbucket.org/1.0/repositories/tutorials/tutorials.bitbucket.org",
... proxies=proxies)
print res.text
{"scm": "hg", "has_wiki": true, "last_updated": "2013-07-19 08:30:48", "creator": null, "forks_count": 3036, "created_on": "2011-12-20 17:35:06", "owner": "tutorials", "logo": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png", "email_mailinglist": "\ndocs@bitbucket.org", "is_mq": false, "size": 50212734, "read_only": false, "fork_of": null, "mq_of": null, "followers_count": 14, "state": "available", "utc_created_on": "2011-12-20 16:35:06+00:00", "website": "", "description": "Site for tutorial101 files", "has_issues": true, "is_fork": false, "slug": "tutorials.bitbucket.org", "is_private": false, "name": "tutorials.bitbucket.org", "language": "html/css", "utc_last_updated": "2013-07-19 06:30:48+00:00", "email_writers": true, "no_public_forks": false, "resource_uri": "/1.0/repositories/tutorials/tutorials.bitbucket.org"} |
The above seems to get rid of the following error: however it seems as though auth still doesn't work when requesting a https page. I'm now getting: Any insight? |
How are you authorising? |
Ignore that, I've spotted the problem. Yeah, with that set of code you won't get the Proxy-Authorization header. I'll mention it over at our PR. |
Hi!
I've found that requests behaves quite weirdly when using a proxy with HTTPS endpoints.
It doesn't change if the proxy is specified using environment variables or using the proxies attribute.
Without proxy
Using a proxy
Note 1: that proxy uses a CNTML authentication
Note 2: it works with HTTP endpoints
The text was updated successfully, but these errors were encountered: