TooManyRedirect on pypi.python.org

I have an issue when I want to request the cheeseshop API, maybe I forget something since the new `0.1` release.

Requests return to me a `TooManyRedirects` exception.
This is my output: https://gist.github.com/4347012


Uh...I can't reproduce this. In fact, I don't get redirects at all. Can you try reinstalling Requests?


I think it's because i'm a behind a firewall and proxies army, but I want to understand why with a simple `curl` cli there is no problem and not with `requests`.

Can you give me some information about debugging to try to understand what's happens ?


Certainly, what would you like to know? =)


I see some issues about redirect and proxy problem. So I think it's more reasonable to wait before taking this seriously.
But basicely, I just want to understand why `curl` success it and not `requests`.

How to start to debug it ?


> How to start to debug it ?

use 'curl -v' and see exactly what curl is doing

Look at http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history and explore the response history of your redirects within requests.

Compare the first request object in your response history with the request and response headers from 'curl -v' and that should give you more insight into what's happening.

I suspect that curl is using a different proxy from requests, or the proxy is handling the request differently for some reason, but that's just a guess.


Thanks @dttocs !
So I catch it, `curl` set a `> Host: pypi.python.org` in header that `requests` doesn't.
When I set it manually it works.

And another thing, `requests` failed to auth on proxy, I have to set myself the `Proxy-Authorization` header.
For information I set proxy like that:

```
 s.get('http://pypi.python.org/pypi/requests/json', proxies={'http':'http://user:pass@myproxy'})
```

My password have some specials characters like `$` for information.

I think it's something already mentionned in another issue. 
I will test with git version of `requests`.

Many thanks.
socketubs.


Taking another look at this, I think this fix might belong in urllib3. The `urllib3.poolmanger.ProxyManager` class has a `_set_proxy_headers` method which should probably set the Host header. Does that sound right, @shazow? If it does, I can offer you a PR with the fix.


@Lukasa There are a bunch of other outstanding pulls, some of which may address this. I haven't gone through my backlog in a while. :( But you're welcome to throw something in just in case.


It's now `1.1.0` and I still have a bug that I failed to identify.
The fact is that is the exactly same situation it works with `requests 0.14.2` and not with the last version.

Requests take my proxy but failed the authentication.
I try to set the proxy in `proxies` argument but same result.

https://gist.github.com/4690235

Maybe I have to create new issue, cause title reflect a fixed bug.


For information I just test it with the `master` (head: 113b67c069) and I have the same issue.


Yes, sorry, I let this slip through my fingers. I'll take another look tonight. =)


@socketubs, I think @Lukasa is close to fixing this for you. (Just to keep you up to date)


Yes! I'll check it very soon and keep you up to date too!
Many thanks guys! :smile: 


I think we're just waiting for @shazow to merge a change over on urllib3 before we pull that in.


Done.


:heart:


Closing