Set https proxies and redirect with a wrong location.

Some of my code are as follows:

```
import requests
#my auth deamon
proxies={'https':'http://10.204.133.76:8080'}    
response=requests.get('https://www.redhat.com',proxies=proxies,allow_redirects=False,verify=False)
```

And response.headers is:

```
CaseInsensitiveDict({'content-length': '0', 'set-cookie': '_zk_sc_tc1=1; HttpOnly, _zk_sc_tc2=1; expires=Wed, 18-Sep-2013 11:58:37 GMT; Path=/; Domain=.redhat.com; HttpOnly', 'connection': 'Keep-Alive', 'location': 'https://auto-scanner-133-76.tmicss.com:443/auth?forward=http%3A%2F%2Fwww.redhat.comhttps%3A%2F%2Fwww.redhat.com%2F', 'date': 'Wed, 11 Sep 2013 11:58:37 GMT', 'p3p': 'CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"', 'content-type': 'text/html; charset=UTF-8'})
```

And the location in the headers is not same as the Browser behavior. And the right 'location' value is 'https://auto-scanner-133-76.tmicss.com:443/auth?forward=https%3A%2F%2Fwww.redhat.com%2F' 

Is this an issue of requests?


Hmm. It looks like your proxy is attaching that header. Out of interest, can you print the Host headers from both outgoing requests? (In requests, you do that by printing `r.request.headers['Host']`).


Hi Lukasa. Thanks for your comments. When I get the headers of requests as follows:
In[5]:response.request.headers
Out[5]: CaseInsensitiveDict({'Accept-Encoding': 'gzip, deflate, compress', 'Accept': '_/_', 'User-Agent': 'python-requests/1.2.2 CPython/2.7.2 Linux/2.6.32-220.el6.x86_64'})
And no Host headers in the requests.
Any comments will be helpful. Thanks a lot.


Uh, yes, sorry, I forgot that we set the Host header lower down. You'd need Wireshark/tcpdump to get the correct headers. Are you familiar with tcpdump or Wireshark?


I try it with the help of Wireshark, and found follow question:
import requests
url = "https://www.redhat.com"
proxies = {"https": "http://10.204.133.76:80"}
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0'}
t = requests.get(url, allow_redirects=False, verify=False, proxies=proxies, headers=headers)
print t.headers
![requests](https://f.cloud.github.com/assets/5434831/1130097/7dc4a184-1b9c-11e3-85fd-fc4b528103a1.png)
From it, it seems that requests use 'GET' other than 'CONNECT' to deal with the https proxy.

And when I use the urllib3 moudle, 
import urllib3
proxy = urllib3.ProxyManager('https://10.204.133.76:80')
r = proxy.request('GET', 'https://www.redhat.com/')
print r.getheaders()
![urllib3](https://f.cloud.github.com/assets/5434831/1130127/3652f94e-1b9d-11e3-993e-cad2f1d6b9a6.jpg)

It seems right. 
I don't know, now requests can support https proxy or not?


New urllib3 supports https proxy over http/connect. This is available in release 1.7. It would be good if requests' copy of urllib3 was updated too.


Requests does not support HTTPS proxies in the current 1.2.3 release. The upcoming 2.0 release of Requests will contain the improved proxy support added to urllib3, including the CONNECT verb. If you would like to test, you can check the 2.0 branch of this repository, which already contains that fix (and many others).

It looks like the 2.0 release will fix your problem!