Skip to content

Commit 438b4fb

Browse files
author
guido
committed
Hack so that if a 302 or 301 redirect contains a relative URL, the
right thing "just happens" (basejoin() with old URL). git-svn-id: http://svn.python.org/projects/python/trunk@13001 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent a1e8177 commit 438b4fb

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Lib/urllib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ def http_error_302(self, url, fp, errcode, errmsg, headers,
451451
return
452452
void = fp.read()
453453
fp.close()
454+
# In case the server sent a relative URL, join with original:
455+
newurl = basejoin("http:" + url, newurl)
454456
return self.open(newurl, data)
455457

456458
# Error 301 -- also relocated (permanently)

0 commit comments

Comments
 (0)