Skip to content

Commit 98587c5

Browse files
authored
Merge pull request #2075 from KOLANICH-libs/netloc
Supported `file` scheme without netloc.
2 parents 6b03ef4 + 35a7dd5 commit 98587c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tuf/ngclient/_internal/requests_fetcher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
import logging
9-
from typing import Dict, Iterator
9+
from typing import Dict, Iterator, Tuple
1010
from urllib import parse
1111

1212
# Imports
@@ -43,7 +43,7 @@ def __init__(self) -> None:
4343
# improve efficiency, but avoiding sharing state between different
4444
# hosts-scheme combinations to minimize subtle security issues.
4545
# Some cookies may not be HTTP-safe.
46-
self._sessions: Dict[str, requests.Session] = {}
46+
self._sessions: Dict[Tuple[str, str], requests.Session] = {}
4747

4848
# Default settings
4949
self.socket_timeout: int = 4 # seconds
@@ -118,10 +118,10 @@ def _get_session(self, url: str) -> requests.Session:
118118
# reuse connections while minimizing subtle security issues.
119119
parsed_url = parse.urlparse(url)
120120

121-
if not parsed_url.scheme or not parsed_url.hostname:
121+
if not parsed_url.scheme:
122122
raise exceptions.DownloadError(f"Failed to parse URL {url}")
123123

124-
session_index = f"{parsed_url.scheme}+{parsed_url.hostname}"
124+
session_index = (parsed_url.scheme, parsed_url.hostname or "")
125125
session = self._sessions.get(session_index)
126126

127127
if not session:

0 commit comments

Comments
 (0)