summaryrefslogtreecommitdiff
path: root/Lib/urllib.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-03-14 08:27:57 +0000
committerGeorg Brandl <georg@python.org>2007-03-14 08:27:57 +0000
commit027ac24650f0cb48d0391ce34749ddfb29419f57 (patch)
treedad6df1c1c34eb9b5ee5356398b43586fb528cb4 /Lib/urllib.py
parent12e8fe63e2d7f10bd1ef43b3c4160d3b42e62223 (diff)
downloadcpython-git-027ac24650f0cb48d0391ce34749ddfb29419f57.tar.gz
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. (backport from rev. 54376)
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r--Lib/urllib.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 9fbb19a419..963187cfb2 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)