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: urllib* 20x responses not OK?
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: kbk Nosy List: facundobatista, georg.brandl, jafo, jimjjewett, kbk
Priority: normal Keywords: patch

Created on 2007-09-18 20:22 by jimjjewett, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib26min2xx.txt jimjjewett, 2007-09-24 14:50
Messages (12)
msg56009 - (view) Author: Jim Jewett (jimjjewett) Date: 2007-09-18 20:22
Under the http protocol, any 2xx response is OK.

urllib.py and urllib2.py hardcoded only response 200 (the most common).


http://bugs.python.org/issue912845 added 206 as acceptable to urllib2, but 
not any other 20x responses.  (It also didn't fix urllib.)

Suggested for 2.6, as it does change behavior.

(Also see duplicate http://bugs.python.org/issue971965 which I will try to 
close after opening this. )
msg56011 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2007-09-18 20:43
It should behave as you say, yes.

I fixed the class HTTPErrorProcessor(BaseHandler) regarding this issue,
to not raise an error if response is 2xx (see rev 54927).

Regards,
msg56014 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2007-09-18 21:18
Facundo: Should this be closed?
msg56016 - (view) Author: Jim Jewett (jimjjewett) Date: 2007-09-18 21:30
Jafo:  His fix is great for urllib2, but the same issue applies to the 
original urllib.

The ticket should not be closed until a similar fix is made to lines 330 and 
417 of urllib.py.

That is, change

"if errcode == 200:" to "if 200 <= errcode < 300:"

(Or, if rejecting the change, add a comment saying that it is left that way 
intentionally for backwards compatibility.)

-jJ
msg56030 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2007-09-19 07:55
Ported code change to urllib, passes tests, committed as revision 58206
msg56031 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-19 08:06
This might need at least a NEWS entry, if not a documentation clarification.
msg56033 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2007-09-19 08:19
Facundo, can you do a NEWS update on this?
msg56037 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2007-09-19 14:05
Done, rev 58207.
msg56113 - (view) Author: Jim Jewett (jimjjewett) Date: 2007-09-24 14:50
The change still missed 
the httpS copy.  I'm 
attaching a minimal change.

I think it might be better 
to just combine the 
methods -- as was already 
done in Py3K.  
Unfortunately, the py3K 
code doesn't run cleanly 
in 2.5, and I haven't yet 
had a chance to test a 
backported equivalent.  
(Hopefully tonight.)
msg56121 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-24 18:08
Applied your patch as r58247.
msg59086 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2008-01-02 04:11
r58207 and r58247 patch logic is reversed.
msg59087 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2008-01-02 04:13
Reversed the logic of the previous patches to urllib.py and added a 
test case.  I noticed the problem when I tried to retrieve a file 
which required auth.

r59661
History
Date User Action Args
2022-04-11 14:56:27adminsetgithub: 45518
2008-01-02 04:13:55kbksetstatus: open -> closed
resolution: fixed
messages: + msg59087
2008-01-02 04:11:41kbksetstatus: closed -> open
assignee: facundobatista -> kbk
resolution: fixed -> (no value)
messages: + msg59086
nosy: + kbk
2007-09-24 18:08:38georg.brandlsetmessages: + msg56121
2007-09-24 14:50:59jimjjewettsetfiles: + urllib26min2xx.txt
messages: + msg56113
2007-09-19 14:05:44facundobatistasetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg56037
2007-09-19 08:19:46jafosetstatus: closed -> open
assignee: facundobatista
messages: + msg56033
keywords: + patch
2007-09-19 08:06:20georg.brandlsetnosy: + georg.brandl
messages: + msg56031
2007-09-19 07:55:19jafosetstatus: open -> closed
resolution: accepted
messages: + msg56030
2007-09-19 06:20:44georg.brandllinkissue971965 superseder
2007-09-18 21:30:46jimjjewettsetmessages: + msg56016
2007-09-18 21:18:50jafosetpriority: normal
nosy: + jafo
messages: + msg56014
2007-09-18 20:43:07facundobatistasetnosy: + facundobatista
messages: + msg56011
2007-09-18 20:22:53jimjjewettcreate