Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
noc
noc
Commits
e0a4045a
Commit
e0a4045a
authored
Jun 15, 2022
by
Andrey Vertiprahov
Browse files
release-22.1:Backport!6380
parent
bd263dfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/http/client.py
View file @
e0a4045a
# ----------------------------------------------------------------------
# HTTP Client
# ----------------------------------------------------------------------
# Copyright (C) 2007-202
0
The NOC Project
# Copyright (C) 2007-202
2
The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
...
...
@@ -205,7 +205,7 @@ async def fetch(
writer
.
write
(
smart_bytes
(
req
))
try
:
await
asyncio
.
wait_for
(
writer
.
drain
(),
request_timeout
)
except
asyncio
.
TimeoutError
:
except
(
asyncio
.
TimeoutError
,
TimeoutError
)
:
metrics
[
"httpclient_proxy_timeouts"
]
+=
1
return
ERR_TIMEOUT
,
{},
b
"Timed out while sending request to proxy"
# Wait for proxy response
...
...
@@ -213,7 +213,7 @@ async def fetch(
while
not
parser
.
is_headers_complete
():
try
:
data
=
await
asyncio
.
wait_for
(
reader
.
read
(
max_buffer_size
),
request_timeout
)
except
asyncio
.
TimeoutError
:
except
(
asyncio
.
TimeoutError
,
TimeoutError
)
:
metrics
[
"httpclient_proxy_timeouts"
]
+=
1
return
ERR_TIMEOUT
,
{},
b
"Timed out while sending request to proxy"
received
=
len
(
data
)
...
...
@@ -282,7 +282,7 @@ async def fetch(
except
ConnectionResetError
:
metrics
[
"httpclient_timeouts"
]
+=
1
return
ERR_TIMEOUT
,
{},
b
"Connection reset while sending request"
except
asyncio
.
TimeoutError
:
except
(
asyncio
.
TimeoutError
,
TimeoutError
)
:
metrics
[
"httpclient_timeouts"
]
+=
1
return
ERR_TIMEOUT
,
{},
b
"Timed out while sending request"
parser
=
HttpParser
()
...
...
@@ -293,7 +293,7 @@ async def fetch(
is_eof
=
not
data
except
(
asyncio
.
IncompleteReadError
,
ConnectionResetError
):
is_eof
=
True
except
asyncio
.
TimeoutError
:
except
(
asyncio
.
TimeoutError
,
TimeoutError
)
:
metrics
[
"httpclient_timeouts"
]
+=
1
return
ERR_READ_TIMEOUT
,
{},
b
"Request timed out"
if
is_eof
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment