Skip to content

Commit af4beb1

Browse files
authored
increase default network timeout (#2542)
* Increase default network timeout * trying to defend against slow retrieval attacks in a generic library is impossible but too low timeouts mean failures in high latency systems (like tests running on CI). Signed-off-by: E3E <ntanzill@purdue.edu>
1 parent 3f896c0 commit af4beb1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tuf/ngclient/_internal/requests_fetcher.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ class RequestsFetcher(FetcherInterface):
2929
3030
Attributes:
3131
socket_timeout: Timeout in seconds, used for both initial connection
32-
delay and the maximum delay between bytes received. Default is
33-
4 seconds.
32+
delay and the maximum delay between bytes received.
3433
chunk_size: Chunk size in bytes used when downloading.
3534
"""
3635

37-
def __init__(self) -> None:
36+
def __init__(
37+
self, socket_timeout: int = 30, chunk_size: int = 400000
38+
) -> None:
3839
# http://docs.python-requests.org/en/master/user/advanced/#session-objects:
3940
#
4041
# "The Session object allows you to persist certain parameters across
@@ -52,8 +53,8 @@ def __init__(self) -> None:
5253
self._sessions: Dict[Tuple[str, str], requests.Session] = {}
5354

5455
# Default settings
55-
self.socket_timeout: int = 4 # seconds
56-
self.chunk_size: int = 400000 # bytes
56+
self.socket_timeout: int = socket_timeout # seconds
57+
self.chunk_size: int = chunk_size # bytes
5758

5859
def _fetch(self, url: str) -> Iterator[bytes]:
5960
"""Fetch the contents of HTTP/HTTPS url from a remote server.

0 commit comments

Comments
 (0)