tests: Check Content-Type header returned from RPC server

Github-Pull: #7833
Rebased-From: 5078ca4543
This commit is contained in:
Wladimir J. van der Laan 2016-04-07 15:21:01 +02:00 committed by MarcoFalke
parent ed2f0e3ac1
commit d5a9de352c

View File

@ -154,6 +154,11 @@ class AuthServiceProxy(object):
raise JSONRPCException({ raise JSONRPCException({
'code': -342, 'message': 'missing HTTP response from server'}) 'code': -342, 'message': 'missing HTTP response from server'})
content_type = http_response.getheader('Content-Type')
if content_type != 'application/json':
raise JSONRPCException({
'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)})
responsedata = http_response.read().decode('utf8') responsedata = http_response.read().decode('utf8')
response = json.loads(responsedata, parse_float=decimal.Decimal) response = json.loads(responsedata, parse_float=decimal.Decimal)
if "error" in response and response["error"] is None: if "error" in response and response["error"] is None: