def _execute_request_raw(self, conn, request): try: result = conn.getresponse() except: raise HapiTimeout(None, request, traceback.format_exc()) result.body = result.read() conn.close() if result.status in (404, 410): raise HapiNotFound(result, request) elif result.status >= 400 and result.status < 500 or result.status == 501: raise HapiBadRequest(result, request) elif result.status >= 500: raise HapiServerError(result, request) return result
def _execute_request_raw(self, conn, request): try: result = conn.getresponse() except: raise HapiTimeout(None, request, traceback.format_exc()) encoding = [ i[1] for i in result.getheaders() if i[0] == 'content-encoding' ] result.body = self._process_body( result.read(), len(encoding) and encoding[0] == 'gzip') conn.close() if result.status in (404, 410): raise HapiNotFound(result, request) elif result.status >= 400 and result.status < 500 or result.status == 501: raise HapiBadRequest(result, request) elif result.status >= 500: raise HapiServerError(result, request) return result