Commit 77769547 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'cherry-pick-273cee03' into 'release-22.1'

release-22.1:Backport!6380

See merge request !6382
parents 9753cae1 e0a4045a
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# HTTP Client # HTTP Client
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project # Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details # See LICENSE for details
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -205,7 +205,7 @@ async def fetch( ...@@ -205,7 +205,7 @@ async def fetch(
writer.write(smart_bytes(req)) writer.write(smart_bytes(req))
try: try:
await asyncio.wait_for(writer.drain(), request_timeout) await asyncio.wait_for(writer.drain(), request_timeout)
except asyncio.TimeoutError: except (asyncio.TimeoutError, TimeoutError):
metrics["httpclient_proxy_timeouts"] += 1 metrics["httpclient_proxy_timeouts"] += 1
return ERR_TIMEOUT, {}, b"Timed out while sending request to proxy" return ERR_TIMEOUT, {}, b"Timed out while sending request to proxy"
# Wait for proxy response # Wait for proxy response
...@@ -213,7 +213,7 @@ async def fetch( ...@@ -213,7 +213,7 @@ async def fetch(
while not parser.is_headers_complete(): while not parser.is_headers_complete():
try: try:
data = await asyncio.wait_for(reader.read(max_buffer_size), request_timeout) data = await asyncio.wait_for(reader.read(max_buffer_size), request_timeout)
except asyncio.TimeoutError: except (asyncio.TimeoutError, TimeoutError):
metrics["httpclient_proxy_timeouts"] += 1 metrics["httpclient_proxy_timeouts"] += 1
return ERR_TIMEOUT, {}, b"Timed out while sending request to proxy" return ERR_TIMEOUT, {}, b"Timed out while sending request to proxy"
received = len(data) received = len(data)
...@@ -282,7 +282,7 @@ async def fetch( ...@@ -282,7 +282,7 @@ async def fetch(
except ConnectionResetError: except ConnectionResetError:
metrics["httpclient_timeouts"] += 1 metrics["httpclient_timeouts"] += 1
return ERR_TIMEOUT, {}, b"Connection reset while sending request" return ERR_TIMEOUT, {}, b"Connection reset while sending request"
except asyncio.TimeoutError: except (asyncio.TimeoutError, TimeoutError):
metrics["httpclient_timeouts"] += 1 metrics["httpclient_timeouts"] += 1
return ERR_TIMEOUT, {}, b"Timed out while sending request" return ERR_TIMEOUT, {}, b"Timed out while sending request"
parser = HttpParser() parser = HttpParser()
...@@ -293,7 +293,7 @@ async def fetch( ...@@ -293,7 +293,7 @@ async def fetch(
is_eof = not data is_eof = not data
except (asyncio.IncompleteReadError, ConnectionResetError): except (asyncio.IncompleteReadError, ConnectionResetError):
is_eof = True is_eof = True
except asyncio.TimeoutError: except (asyncio.TimeoutError, TimeoutError):
metrics["httpclient_timeouts"] += 1 metrics["httpclient_timeouts"] += 1
return ERR_READ_TIMEOUT, {}, b"Request timed out" return ERR_READ_TIMEOUT, {}, b"Request timed out"
if is_eof: if is_eof:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment