[Python-bugs-list] [ python-Bugs-588714 ] urllib.urlopen.geturl() and redirects

noreply@sourceforge.net noreply@sourceforge.net
Tue, 30 Jul 2002 12:11:43 -0700


Bugs item #588714, was opened at 2002-07-30 19:11
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=588714&group_id=5470

Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthias Klose (doko)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib.urlopen.geturl() and redirects

Initial Comment:
[From http://bugs.debian.org/146408]

From: Matthew Vernon <matthew@pick.ucam.org>
Subject: python2.2: urllib.urlopen.geturl() fails to
deal with redirects properly

urllib.urlopen.geturl() claims: "

The geturl() method returns the real URL of the page.
In some cases,
the HTTP server redirects a client to another URL. The
urlopen()
function handles this transparently, but in some cases
the caller
needs to know which URL the client was redirected to.
The geturl()
method can be used to get at this redirected URL.

But it appears not to:

>>>
urllib.urlopen("http://www.google.com/search?q=test&btnI=I'm+Feeling+Lucky").geturl()
"http://www.google.com/search?q=test&btnI=I'm+Feeling+Lucky"

Doing the same by steam:

HEAD
http://www.google.com/search?q=test&btnI=I'm+Feeling+Lucky
HTTP/1.1
Host: www.google.com

HTTP/1.0 302 Moved Temporarily
Content-Length: 151
Server: GWS/2.0
Date: Thu, 09 May 2002 16:51:37 GMT
Location: http://www.toefl.org/
Content-Type: text/html



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=588714&group_id=5470