diff options
author | Georg Brandl <georg@python.org> | 2007-03-14 08:27:52 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-03-14 08:27:52 (GMT) |
commit | f66b6039c11fb8f9162867afb7e6574652637a7b (patch) | |
tree | 08135659eca3719afcce22a6fdf4a84d6f6fad34 /Lib/urllib.py | |
parent | 90fd76a2b49353fc43ab48b330a6e752ed9a75ba (diff) | |
download | cpython-f66b6039c11fb8f9162867afb7e6574652637a7b.zip cpython-f66b6039c11fb8f9162867afb7e6574652637a7b.tar.gz cpython-f66b6039c11fb8f9162867afb7e6574652637a7b.tar.bz2 |
Bug #767111: fix long-standing bug in urllib which caused an
AttributeError instead of an IOError when the server's response didn't
contain a valid HTTP status line.
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index 0fc9b28..c000f11 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -326,6 +326,10 @@ class URLopener: if data is not None: h.send(data) errcode, errmsg, headers = h.getreply() + if errcode == -1: + # something went wrong with the HTTP status line + raise IOError, ('http protocol error', 0, + 'got a bad status line', None) fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "http:" + url) @@ -413,6 +417,10 @@ class URLopener: if data is not None: h.send(data) errcode, errmsg, headers = h.getreply() + if errcode == -1: + # something went wrong with the HTTP status line + raise IOError, ('http protocol error', 0, + 'got a bad status line', None) fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "https:" + url) |