File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66"""
77
88import logging
9- from typing import Dict , Iterator
9+ from typing import Dict , Iterator , Tuple
1010from 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 :
You can’t perform that action at this time.
0 commit comments