Skip to content
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

urrlib2 max_redirections=0 disables redirects #43650

Closed
rusrorange mannequin opened this issue Jul 11, 2006 · 9 comments
Closed

urrlib2 max_redirections=0 disables redirects #43650

rusrorange mannequin opened this issue Jul 11, 2006 · 9 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@rusrorange
Copy link
Mannequin

rusrorange mannequin commented Jul 11, 2006

BPO 1520831
Nosy @orsenthil, @devdanzin

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/orsenthil'
closed_at = <Date 2010-11-13.12:25:45.822>
created_at = <Date 2006-07-11.22:16:22.000>
labels = ['type-feature', 'library']
title = 'urrlib2 max_redirections=0 disables redirects'
updated_at = <Date 2010-11-20.21:03:28.129>
user = 'https://bugs.python.org/rusrorange'

bugs.python.org fields:

activity = <Date 2010-11-20.21:03:28.129>
actor = 'jjlee'
assignee = 'orsenthil'
closed = True
closed_date = <Date 2010-11-13.12:25:45.822>
closer = 'orsenthil'
components = ['Library (Lib)']
creation = <Date 2006-07-11.22:16:22.000>
creator = 'rus_r_orange'
dependencies = []
files = []
hgrepos = []
issue_num = 1520831
keywords = []
message_count = 9.0
messages = ['60939', '81785', '116168', '121131', '121141', '121222', '121241', '121696', '121775']
nosy_count = 4.0
nosy_names = ['jjlee', 'orsenthil', 'ajaksu2', 'rus_r_orange']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue1520831'
versions = ['Python 3.2']

@rusrorange
Copy link
Mannequin Author

rusrorange mannequin commented Jul 11, 2006

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.

@rusrorange rusrorange mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jul 11, 2006
@devdanzin
Copy link
Mannequin

devdanzin mannequin commented Feb 12, 2009

rus_r_orange: Can you share your patch and tests?

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Sep 12, 2010

Senthil/John has this simply slipped under the radar?

@orsenthil
Copy link
Member

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.

@jjlee
Copy link
Mannequin

jjlee mannequin commented Nov 13, 2010

Why not?

@orsenthil
Copy link
Member

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.

@jjlee
Copy link
Mannequin

jjlee mannequin commented Nov 15, 2010

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.

@orsenthil
Copy link
Member

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?

@jjlee
Copy link
Mannequin

jjlee mannequin commented Nov 20, 2010

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 (!).

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant