mirror of
https://github.com/python/cpython.git
synced 2025-08-17 23:31:09 +00:00
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)
This commit is contained in:
parent
12e8fe63e2
commit
027ac24650
3 changed files with 21 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue