classification
Title: Improve redirection in urllib
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.4, Python 3.3, Python 3.2, Python 3.1
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, orsenthil, tom.kel
Priority: normal Keywords: patch

Created on 2011-12-22 18:09 by tom.kel, last changed 2012-01-27 02:10 by tom.kel.

Files
File name Uploaded Description Edit
http-redirect-3.2.diff tom.kel, 2011-12-22 18:09
2012-1-26.diff tom.kel, 2012-01-27 02:10
Messages (4)
msg150103 - (view) Author: tom kel (tom.kel) Date: 2011-12-22 18:09
refer to patch for improvements
msg150104 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011-12-22 18:11
Can you explain the patch and state why you would like that change included?

This would require a test.
msg150105 - (view) Author: tom kel (tom.kel) Date: 2011-12-22 18:41
I created this patch to further the functionality of redirection using the "location" header in the HTTPRedirectHandler class under urllib/request.py

Currently, the method http_error_302, which will handle code 302 redirection will parse the location header and build a Request accordingly. I encountered a website that only returned "index.php" as the Location header. When http_error_302 called on urlparse, it returned the following tuple: ParseResult(scheme='', netloc='', path='index.php', params='', query='', fragment='')

Then, http_error_302 will check if the scheme is equal to either http, https, or ftp. This is the part I changed in the patch. If it does not pass, an exception is thrown.

Afterwards, http_error_302 builds the target url. As long as the url passes the scheme check, the program will succeed.
msg152059 - (view) Author: tom kel (tom.kel) Date: 2012-01-27 02:10
I changed the patch and made it a little bit better.
History
Date User Action Args
2012-01-27 02:10:39tom.kelsetfiles: + 2012-1-26.diff

messages: + msg152059
versions: + Python 3.1, Python 3.4, - Python 2.7
2011-12-23 14:51:49pitrousetnosy: + orsenthil

versions: + Python 2.7, - Python 3.4
2011-12-22 18:41:26tom.kelsetmessages: + msg150105
2011-12-22 18:11:37brian.curtinsetnosy: + brian.curtin
messages: + msg150104
2011-12-22 18:09:38tom.kelcreate