[issue13650] urllib HTTPRedirectHandler does not implement documented behavior
New submission from tom kel : Python 3.2.2, Here is a blokck of code from the HTTPRedirectHandler: m = req.get_method() if (not (code in (301, 302, 303, 307) and m in ("GET", "HEAD") or code in (301, 302, 303) and m == "POST")): raise HTTPError(req.full_url, code, msg, headers, fp) # Strictly (according to RFC 2616), 301 or 302 in response to # a POST MUST NOT cause a redirection without confirmation # from the user (of urllib.request, in this case). In practice, # essentially all clients do redirect in this case, so we do # the same. As you can see, the documentation and the implementation are contradictory. -- components: Library (Lib) messages: 150102 nosy: tom.kel priority: normal severity: normal status: open title: urllib HTTPRedirectHandler does not implement documented behavior type: behavior versions: Python 3.2 ___ Python tracker <http://bugs.python.org/issue13650> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13650] urllib HTTPRedirectHandler does not implement documented behavior
Changes by tom kel : -- status: open -> closed ___ Python tracker <http://bugs.python.org/issue13650> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13651] Improve redirection in urllib
New submission from tom kel : refer to patch for improvements -- components: Library (Lib) files: http-redirect-3.2.diff keywords: patch messages: 150103 nosy: tom.kel priority: normal severity: normal status: open title: Improve redirection in urllib type: enhancement versions: Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file24076/http-redirect-3.2.diff ___ Python tracker <http://bugs.python.org/issue13651> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13651] Improve redirection in urllib
tom kel added the comment: 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. -- ___ Python tracker <http://bugs.python.org/issue13651> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13651] Improve redirection in urllib
tom kel added the comment: I changed the patch and made it a little bit better. -- versions: +Python 3.1, Python 3.4 -Python 2.7 Added file: http://bugs.python.org/file24334/2012-1-26.diff ___ Python tracker <http://bugs.python.org/issue13651> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com