Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _execute_request_raw(self, conn, request):
try:
result = conn.getresponse()
except Exception:
raise HubspotTimeout(None, request, traceback.format_exc())
encoding = [i[1] for i in result.getheaders() if i[0] == "content-encoding"]
possibly_encoded = result.read()
try:
possibly_encoded = zlib.decompress(possibly_encoded, 16 + zlib.MAX_WBITS)
except Exception:
pass
result.body = self._process_body(
possibly_encoded, len(encoding) and encoding[0] == "gzip"
)
conn.close()
if result.status in (404, 410):
raise HubspotNotFound(result, request)
if result.status == 401:
raise HubspotUnauthorized(result, request)