This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improve redirection in urllib
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: [urllib.request.HTTPRedirectHandler.http_error_302] Relative Redirect issue
View: 13696
Assigned To: Nosy List: brian.curtin, christian.heimes, orsenthil, tkel
Priority: normal Keywords: patch

Created on 2011-12-22 18:09 by tkel, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
http-redirect-3.2.diff tkel, 2011-12-22 18:09
2012-1-26.diff tkel, 2012-01-27 02:10
Messages (5)
msg150103 - (view) Author: Tommy Kelly (tkel) 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: Tommy Kelly (tkel) 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: Tommy Kelly (tkel) Date: 2012-01-27 02:10
I changed the patch and made it a little bit better.
msg192375 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-05 23:28
New features have to go into 3.4
History
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57860
2016-07-31 03:38:24martin.pantersetstatus: open -> closed
superseder: [urllib.request.HTTPRedirectHandler.http_error_302] Relative Redirect issue
resolution: duplicate
stage: resolved
2014-01-31 23:37:17yselivanovsetversions: + Python 3.5, - Python 3.4
2013-07-05 23:28:41christian.heimessetnosy: + christian.heimes

messages: + msg192375
versions: - Python 3.1, Python 3.2, Python 3.3
2012-01-27 02:10:39tkelsetfiles: + 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:26tkelsetmessages: + msg150105
2011-12-22 18:11:37brian.curtinsetnosy: + brian.curtin
messages: + msg150104
2011-12-22 18:09:38tkelcreate