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: urllib2 checks for http return code 200 only.
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, heresiarch, oneofone
Priority: normal Keywords:

Created on 2004-03-09 16:32 by oneofone, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg20185 - (view) Author: Ahmed F. (oneofone) Date: 2004-03-09 16:32
from urllib2 import *
req = Request("http://someurl/page.html",
headers={'range: bytes=%s':'20-40'})
result = urlopen(req)

will die with something like :
  File "/usr/lib/python2.3/urllib2.py", line 306, in
_call_chain
    result = func(*args)
  File "/usr/lib/python2.3/urllib2.py", line 412, in
http_error_default
    raise HTTPError(req.get_full_url(), code, msg,
hdrs, fp)
urllib2.HTTPError: HTTP Error 206: Partial Content


line 892 in {PATH}/urllib2.py should be changed from :
if code == 200:
to
if code in [200, 206]:

peace

msg20186 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-06-29 13:19
Logged In: YES 
user_id=11375

Applied to CVS; thanks!
msg20187 - (view) Author: Drew (heresiarch) Date: 2006-06-05 01:19
Logged In: YES 
user_id=1534250

While it's good that 200 and 206 are not considered errors,
what about 201-205? Per the HTTP RFC
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2)
all 2xx codes should be considered successful responses and
probably shouldn't trigger errors.

Thanks!
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40018
2004-03-09 16:32:25oneofonecreate