msg60939 - (view) |
Author: rus_r_orange (rus_r_orange) |
Date: 2006-07-11 22:16 |
When using urllib2, I wanted to be able to see all redirects that come back from an http server. I set the variable max_redirections in HTTPRedirectHandler to 0. However, redirects were still being followed because the req didn't have a redirect_dict set. IMHO, if max_redirections is set to 0, redirects should not be followed, no matter what. For my personal situation, I copied urllib2 and hacked it to that if max_redirections is 0 (or less), it will always raise the HTTPError that is associated with the status code received by the request. I saw this issue on WinXP with 2.4.1 and on Linux with 2.4.3. |
|
|
msg81785 - (view) |
Author: Daniel Diniz (ajaksu2) *  |
Date: 2009-02-12 17:39 |
rus_r_orange: Can you share your patch and tests? |
|
|
msg116168 - (view) |
Author: Mark Lawrence (BreamoreBoy) * |
Date: 2010-09-12 10:48 |
Senthil/John has this simply slipped under the radar? |
|
|
msg121131 - (view) |
Author: Senthil Kumaran (orsenthil) *  |
Date: 2010-11-13 12:25 |
This is an invalid bug report at the moment. In fact, aged. The redirection depends upon max_redirections and max_repeats together. Setting it to 0 explicitly (inside the code) is not a good use case under any condition. |
|
|
msg121141 - (view) |
Author: John J Lee (jjlee) |
Date: 2010-11-13 15:31 |
Why not? |
|
|
msg121222 - (view) |
Author: Senthil Kumaran (orsenthil) *  |
Date: 2010-11-15 11:31 |
John, I was trying to find out what does rfc say on "Client Ignoring the 30X REDIRECT headers". There is no point made on Client's trying to ignore it, instead it said that it should follow the Redirect and must not endlessly loop. Setting max_redirect to 0 is similar to ignoring the redirect request , which I found to be a bad idea under any case. Also, if one has to just see redirect urls coming from http server, it can be done by subclassing the HTTPRedirectHandler and logging the redirects. |
|
|
msg121241 - (view) |
Author: John J Lee (jjlee) |
Date: 2010-11-15 20:55 |
That's silly. A justification of the need for a new feature isn't needed, because this is already-implemented feature that simply does the wrong thing at the edge case. It's not high priority, but it is a bug. |
|
|
msg121696 - (view) |
Author: Senthil Kumaran (orsenthil) *  |
Date: 2010-11-20 17:54 |
What should it do? OP expected that it print the redirected url. I don't think that's helpful by setting max_redirections to 0, when it can be achieved in other ways. Also, max_redirections is not exposed (as a parameter or arg) or a documented, how do we define user's expectation when he tries to change it? |
|
|
msg121775 - (view) |
Author: John J Lee (jjlee) |
Date: 2010-11-20 21:03 |
Oops, I hadn't noticed that max_redirections isn't part of the API. In that case, I agree that it's not strictly a bug. I'd also agree it's not very important. FWIW: "want[ing] to see all redirects" is not the same thing as printing URLs -- I assume he simply meant that he wanted .open to return the original response, and not a redirected response. I don't think he meant that he wanted urllib2 itself to allow him to literally see the URLs on his screen, by printing them to stdout (!). |
|
|