Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions tuf/ngclient/_internal/requests_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"""

import logging
import time
from typing import Dict, Iterator, Optional
from typing import Dict, Iterator
from urllib import parse

# Imports
Expand Down Expand Up @@ -51,7 +50,6 @@ def __init__(self) -> None:
# Default settings
self.socket_timeout: int = 4 # seconds
self.chunk_size: int = 400000 # bytes
self.sleep_before_round: Optional[int] = None

def fetch(self, url: str) -> Iterator[bytes]:
"""Fetches the contents of HTTP/HTTPS url from a remote server
Expand Down Expand Up @@ -104,11 +102,7 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
# We download a fixed chunk of data in every round. This is
# so that we can defend against slow retrieval attacks.
# Furthermore, we do not wish to download an extremely
# large file in one shot. Before beginning the round, sleep
# (if set) for a short amount of time so that the CPU is not
# hogged in the while loop.
if self.sleep_before_round:
time.sleep(self.sleep_before_round)
# large file in one shot.

# NOTE: This may not handle some servers adding a
# Content-Encoding header, which may cause urllib3 to
Expand Down