proxy with authentication fails in requests 2.0

It seems new version broke proxy with authentication when using proxy_url of the form http://username:password@proxy_url

test script output from version 1.2.3

INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): obproxy.telegraaf.net
send: 'GET http://nu.nl HTTP/1.1\r\nHost: www.cleafs.nl\r\nProxy-Authorization: Basic 34hdsfhkjhs95jfsdkljf\r\nAccept-Encoding: gzip, deflate, compress\r\nAccept: _/_\r\nUser-Agent: python-requests/1.2.3 CPython/2.7.3 

while exactly same script in requests 2.0 doesnt send basic auth header and gets a request denied from proxy

INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 

PROXY Url(scheme='http', auth='username:password', host='obproxy.telegraaf.net', port=3128, path=None, query=None, fragment=None)
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): obproxy.telegraaf.net
send: 'GET http://www.nu.nl/ HTTP/1.1\r\nHost: www.nu.nl\r\nAccept-Encoding: gzip, deflate, compress\r\nAccept: _/_\r\nUser-Agent: python-requests/2.0.0 CPython/2.7.3 Linux/3.7.2-vs2.3.5.5-d64-i7\r\n\r\n'
DEBUG:requests.packages.urllib3.connectionpool:Setting read timeout to <object object at 0x7feaa083b0e0>
reply: 'HTTP/1.0 407 Proxy Authentication Required\r\n'


It actually only broke it for HTTP proxies, HTTPS proxies work fine. =)

I'm currently considering a fix in urllib3, which you can see at shazow/urllib3#271. In the meantime, you can apply the `HTTPProxyAuth` auth handler, which will do the right thing.


after some googling I found the
auth = HTTPProxyAuth(username, password)
possiblity, and that works.

Might be worth considering updating the documentation cause there it states explictly to use the not working method.
http://www.python-requests.org/en/latest/user/advanced/
To use HTTP Basic Auth with your proxy, use the http://user:password@host/ syntax:

By the way I think I will update my proxy password:-)


I can fix the documentation if that's what's needed. (Yes, I'm searching for easy stuff!)


The documentation isn't broken, the code is. The documentation shows what _should _ work, and currently it doesn't. The docs are not the right place to handle temporary bugs. =)


Hmm I could take a look at the code too


@canibanoglu Heh, this is not a great beginner problem. This issue is that, when HTTPS proxies were added to urllib3 they added a `proxy_headers` parameter which adds headers to all messages sent via a proxy. This is clearly the right place for `Proxy Authorization` to go. However, it turns out urllib3 only applies the HTTP versions when you use `ProxyManager.urlopen()`, which Requests doesn't do. Hence the work I'm doing in urllib3 to try to make some kind of consistent interface. =)


Oh well, I'll get to that level as well


@canibanoglu The question is not actually technically difficult, but it's about how urllib3 should be structured and how its interfaces should be used. You're easily technically good enough to do it: the only advantage I have is that I'm familiar with urllib3. =) I invite you to take a look at the issues I linked to above, and consider how you'd solve them. If you come up with a solution you like, open a pull request. I'm always happy for you to do the work instead of me!


This should be fixed in the next release of Requests.


Looking forward for the fix.


Fixed in 2.1.0.