mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Document DownloadError for RequestsFetcher.fetch()
We should document that "DownloadError" is thrown inside RequestsFetcher.fetch(). Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
This commit is contained in:
parent
8327ea12d3
commit
7bb916f962
1 changed files with 5 additions and 1 deletions
|
|
@ -61,6 +61,7 @@ def fetch(self, url: str) -> Iterator[bytes]:
|
|||
exceptions.SlowRetrievalError: A timeout occurs while receiving
|
||||
data.
|
||||
exceptions.FetcherHTTPError: An HTTP error code is received.
|
||||
exceptions.DownloadError: When there is a problem parsing the url.
|
||||
|
||||
Returns:
|
||||
A bytes iterator
|
||||
|
|
@ -126,13 +127,16 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
|
|||
def _get_session(self, url: str) -> requests.Session:
|
||||
"""Returns a different customized requests.Session per schema+hostname
|
||||
combination.
|
||||
|
||||
Raises:
|
||||
exceptions.DownloadError: When there is a problem parsing the url.
|
||||
"""
|
||||
# Use a different requests.Session per schema+hostname combination, to
|
||||
# reuse connections while minimizing subtle security issues.
|
||||
parsed_url = parse.urlparse(url)
|
||||
|
||||
if not parsed_url.scheme or not parsed_url.hostname:
|
||||
raise exceptions.DownloadError("Failed to parse URL")
|
||||
raise exceptions.DownloadError("Failed to parse URL {url}")
|
||||
|
||||
session_index = parsed_url.scheme + "+" + parsed_url.hostname
|
||||
session = self._sessions.get(session_index)
|
||||
|
|
|
|||
Loading…
Reference in a new issue