Skip to content

Commit

Permalink
Merge 91e82be into d9153ee
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Aug 11, 2022
2 parents d9153ee + 91e82be commit 22dbc6f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tuf/ngclient/_internal/requests_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
finally:
response.close()

SCHEMES_WITHOUT_HOSTNAME = {"file"}

def _get_session(self, url: str) -> requests.Session:
"""Returns a different customized requests.Session per schema+hostname
combination.
Expand All @@ -118,7 +120,7 @@ def _get_session(self, url: str) -> requests.Session:
# reuse connections while minimizing subtle security issues.
parsed_url = parse.urlparse(url)

if not parsed_url.scheme or not parsed_url.hostname:
if not parsed_url.scheme or (not parsed_url.hostname and parsed_url.scheme not in self.SCHEMES_WITHOUT_HOSTNAME):
raise exceptions.DownloadError(f"Failed to parse URL {url}")

session_index = f"{parsed_url.scheme}+{parsed_url.hostname}"
Expand Down

0 comments on commit 22dbc6f

Please sign in to comment.