@@ -274,7 +274,7 @@ def request_host(request):
274274
275275 """
276276 url = request .full_url
277- host = urlparse (url )[ 1 ]
277+ host = urlparse (url ). netloc
278278 if host == "" :
279279 host = request .get_header ("Host" , "" )
280280
@@ -832,11 +832,11 @@ def reduce_uri(self, uri, default_port=True):
832832 """Accept authority or URI and extract only the authority and path."""
833833 # note HTTP URLs do not have a userinfo component
834834 parts = urlsplit (uri )
835- if parts [ 1 ] :
835+ if parts . netloc :
836836 # URI
837- scheme = parts [ 0 ]
838- authority = parts [ 1 ]
839- path = parts [ 2 ] or '/'
837+ scheme = parts . scheme
838+ authority = parts . netloc
839+ path = parts . path or '/'
840840 else :
841841 # host or host:port
842842 scheme = None
@@ -1209,7 +1209,7 @@ class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
12091209 handler_order = 490 # before Basic auth
12101210
12111211 def http_error_401 (self , req , fp , code , msg , headers ):
1212- host = urlparse (req .full_url )[ 1 ]
1212+ host = urlparse (req .full_url ). netloc
12131213 retry = self .http_error_auth_reqed ('www-authenticate' ,
12141214 host , req , headers )
12151215 self .reset_retry_count ()
@@ -1668,7 +1668,9 @@ def url2pathname(url, *, require_scheme=False, resolve_host=False):
16681668 """
16691669 if not require_scheme :
16701670 url = 'file:' + url
1671- scheme , authority , url = urlsplit (url )[:3 ] # Discard query and fragment.
1671+ parts = urlsplit (url )
1672+ # Discard query and fragment.
1673+ scheme , authority , url = parts .scheme , parts .netloc , parts .path
16721674 if scheme != 'file' :
16731675 raise URLError ("URL is missing a 'file:' scheme" )
16741676 if os .name == 'nt' :
0 commit comments