check http request status before attempting to decode response

This commit is contained in:
Mike McLean 2017-01-30 11:13:46 +01:00
parent b1537a73ba
commit eb7a1e369f
2 changed files with 6 additions and 0 deletions

View file

@ -2321,6 +2321,7 @@ class ClientSession(object):
if catcher:
warnings.simplefilter("ignore")
r = self.rsession.post(handler, **callopts)
r.raise_for_status()
try:
ret = self._read_xmlrpc_response(r)
finally:

View file

@ -121,6 +121,11 @@ class Response(object):
self.session = session
self.response = response
def raise_for_status(self):
if self.response.status >= 400:
raise httplib.HTTPException("HTTP %s: %s" % (self.response.status,
self.response.reason))
def iter_content(self, blocksize=8192):
# should we check this in Session.post()?
# should we even check this here?