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

urllib2 raises exception when page redirects to itself #42743

Closed
rpijlman mannequin opened this issue Dec 31, 2005 · 2 comments
Closed

urllib2 raises exception when page redirects to itself #42743

rpijlman mannequin opened this issue Dec 31, 2005 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@rpijlman
Copy link
Mannequin

rpijlman mannequin commented Dec 31, 2005

BPO 1394453

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 = None
closed_at = <Date 2005-12-31.18:10:31.000>
created_at = <Date 2005-12-31.16:46:15.000>
labels = ['library']
title = 'urllib2 raises exception when page redirects to itself'
updated_at = <Date 2005-12-31.18:10:31.000>
user = 'https://bugs.python.org/rpijlman'

bugs.python.org fields:

activity = <Date 2005-12-31.18:10:31.000>
actor = 'rpijlman'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2005-12-31.16:46:15.000>
creator = 'rpijlman'
dependencies = []
files = []
hgrepos = []
issue_num = 1394453
keywords = []
message_count = 2.0
messages = ['27192', '27193']
nosy_count = 1.0
nosy_names = ['rpijlman']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1394453'
versions = ['Python 2.3']

@rpijlman
Copy link
Mannequin Author

rpijlman mannequin commented Dec 31, 2005

Some sites redirect a page to itself, due to a
configuration error or bug. The popular browsers seem
to be forgiving: when a URL redirects to itself, they
break the infinite redirect loop and simply display the
page (verified in IE6 and Firefox 1.5).

urllib2.urlopen() raises an exception in the same
situation: HTTP Error 302: The HTTP server returned a
redirect error that would lead to an infinite loop.

Although this message is technically correct, I think
the situation of a page redirecting to itself should be
handled as a special case. It should abort the redirect
and continue with the current request. Users expect
urllib to be able to access sites that popular browsers
can apparently access without problems.

To reproduce (pick a site with this redirect anomaly):

import urllib2
try:
    handle =
urllib2.urlopen('http://www.haselhoff.nl/default.asp')
except IOError,e:
    print str(e)

Reproduced with Python 2.3.5 on Windows XP and Linux.
Also with today's trunk (2.5).

@rpijlman rpijlman mannequin closed this as completed Dec 31, 2005
@rpijlman rpijlman mannequin added the stdlib Python modules in the Lib dir label Dec 31, 2005
@rpijlman rpijlman mannequin closed this as completed Dec 31, 2005
@rpijlman rpijlman mannequin added the stdlib Python modules in the Lib dir label Dec 31, 2005
@rpijlman
Copy link
Mannequin Author

rpijlman mannequin commented Dec 31, 2005

Logged In: YES
user_id=1416482

Forget it. I misunderstood. The reason some sites redirect
to the current page itself, is to first set a cookie.

I retried with cookie support in urllib2 and cookielib in
Python 2.4. With HTTPCookieProcessor installed as opener
urllib2.urlopen worked fine on two different sites that
showed this 'problem'.

@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
Projects
None yet
Development

No branches or pull requests

0 participants