Fetcher
Provides an interface for network IO abstraction.
- class FetcherInterface
Defines an interface for abstract network download.
By providing a concrete implementation of the abstract interface, users of the framework can plug-in their preferred/customized network stack.
- download_bytes(url, max_length)
Download bytes from given url
Returns the downloaded bytes, otherwise like download_file()
- Parameters
url (str) –
max_length (int) –
- Return type
bytes
- download_file(url, max_length)
Opens a connection to ‘url’ and downloads the content up to ‘max_length’.
- Parameters
url (str) – a URL string that represents the location of the file.
max_length (int) – an integer value representing the length of the file or an upper bound.
- Raises
DownloadLengthMismatchError – downloaded bytes exceed ‘max_length’.
- Yields
A TemporaryFile object that points to the contents of ‘url’.
- Return type
Iterator[IO]
- abstract fetch(url)
Fetches the contents of HTTP/HTTPS url from a remote server.
- Parameters
url (str) – A URL string that represents a file location.
- Raises
tuf.exceptions.SlowRetrievalError – A timeout occurs while receiving data.
tuf.exceptions.FetcherHTTPError – An HTTP error code is received.
- Returns
A bytes iterator
- Return type
Iterator[bytes]