Issue 1177: urllib* 20x responses not OK? (original) (raw)

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:27 admin set github: 45518
2008-01-02 04:13:55 kbk set status: open -> closedresolution: fixedmessages: +
2008-01-02 04:11:41 kbk set status: closed -> openassignee: facundobatista -> kbkresolution: fixed -> (no value)messages: + nosy: + kbk
2007-09-24 18:08:38 georg.brandl set messages: +
2007-09-24 14:50:59 jimjjewett set files: + urllib26min2xx.txtmessages: +
2007-09-19 14:05:44 facundobatista set status: open -> closedresolution: accepted -> fixedmessages: +
2007-09-19 08:19:46 jafo set status: closed -> openassignee: facundobatistamessages: + keywords: + patch
2007-09-19 08:06:20 georg.brandl set nosy: + georg.brandlmessages: +
2007-09-19 07:55:19 jafo set status: open -> closedresolution: acceptedmessages: +
2007-09-19 06:20:44 georg.brandl link issue971965 superseder
2007-09-18 21:30:46 jimjjewett set messages: +
2007-09-18 21🔞50 jafo set priority: normalnosy: + jafomessages: +
2007-09-18 20:43:07 facundobatista set nosy: + facundobatistamessages: +
2007-09-18 20:22:53 jimjjewett create