2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-14 19:57:47 +00:00

Convert BadStatusLine result

If the BMC violates HTTP specification,
just make it equivalent to a 500
error.

Change-Id: I66f5cb5b39f03a6c738b1e52e596fd6bdc73c0bd
This commit is contained in:
Jarrod Johnson 2019-12-05 14:45:36 -05:00
parent 1c50fcbcfe
commit dec668cc21

View File

@ -208,7 +208,14 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
if not method:
method = 'GET'
webclient.request(method, url, referer=referer, headers=headers)
rsp = webclient.getresponse()
try:
rsp = webclient.getresponse()
except httplib.BadStatusLine:
return 'Target Unavailable', 500
except ssl.SSLError as e:
if 'timed out' in str(e):
return 'Target Unavailable', 500
raise
body = rsp.read()
if rsp.getheader('Content-Encoding', None) == 'gzip':
body = gzip.GzipFile(fileobj=io.BytesIO(body)).read()