1919from ._content_streams import ContentStream
2020from ._exceptions import (
2121 HTTPCORE_EXC_MAP ,
22- InvalidURL ,
2322 RequestBodyUnavailable ,
2423 TooManyRedirects ,
2524 map_exceptions ,
4443from ._utils import (
4544 NetRCInfo ,
4645 URLPattern ,
47- enforce_http_url ,
4846 get_environment_proxies ,
4947 get_logger ,
5048 same_origin ,
@@ -344,11 +342,6 @@ def _redirect_url(self, request: Request, response: Response) -> URL:
344342
345343 url = URL (location )
346344
347- # Check that we can handle the scheme
348- if url .scheme and url .scheme not in ("http" , "https" ):
349- message = f'Scheme "{ url .scheme } " not supported.'
350- raise InvalidURL (message , request = request )
351-
352345 # Handle malformed 'Location' headers that are "absolute" form, have no host.
353346 # See: https://github.com/encode/httpx/issues/771
354347 if url .scheme and not url .host :
@@ -540,8 +533,8 @@ def _init_transport(
540533
541534 return httpcore .SyncConnectionPool (
542535 ssl_context = ssl_context ,
543- max_keepalive = limits .max_keepalive ,
544536 max_connections = limits .max_connections ,
537+ max_keepalive_connections = limits .max_keepalive_connections ,
545538 keepalive_expiry = KEEPALIVE_EXPIRY ,
546539 http2 = http2 ,
547540 )
@@ -562,20 +555,17 @@ def _init_proxy_transport(
562555 proxy_headers = proxy .headers .raw ,
563556 proxy_mode = proxy .mode ,
564557 ssl_context = ssl_context ,
565- max_keepalive = limits .max_keepalive ,
566558 max_connections = limits .max_connections ,
559+ max_keepalive_connections = limits .max_keepalive_connections ,
567560 keepalive_expiry = KEEPALIVE_EXPIRY ,
568561 http2 = http2 ,
569562 )
570563
571- def _transport_for_url (self , request : Request ) -> httpcore .SyncHTTPTransport :
564+ def _transport_for_url (self , url : URL ) -> httpcore .SyncHTTPTransport :
572565 """
573566 Returns the transport instance that should be used for a given URL.
574567 This will either be the standard connection pool, or a proxy.
575568 """
576- url = request .url
577- enforce_http_url (request )
578-
579569 for pattern , transport in self ._proxies .items ():
580570 if pattern .matches (url ):
581571 return self ._transport if transport is None else transport
@@ -620,10 +610,6 @@ def send(
620610 allow_redirects : bool = True ,
621611 timeout : typing .Union [TimeoutTypes , UnsetType ] = UNSET ,
622612 ) -> Response :
623- if request .url .scheme not in ("http" , "https" ):
624- message = 'URL scheme must be "http" or "https".'
625- raise InvalidURL (message , request = request )
626-
627613 timeout = self .timeout if isinstance (timeout , UnsetType ) else Timeout (timeout )
628614
629615 auth = self ._build_auth (request , auth )
@@ -714,7 +700,7 @@ def _send_single_request(self, request: Request, timeout: Timeout) -> Response:
714700 """
715701 Sends a single request, without handling any redirections.
716702 """
717- transport = self ._transport_for_url (request )
703+ transport = self ._transport_for_url (request . url )
718704
719705 with map_exceptions (HTTPCORE_EXC_MAP , request = request ):
720706 (
@@ -1072,8 +1058,8 @@ def _init_transport(
10721058
10731059 return httpcore .AsyncConnectionPool (
10741060 ssl_context = ssl_context ,
1075- max_keepalive = limits .max_keepalive ,
10761061 max_connections = limits .max_connections ,
1062+ max_keepalive_connections = limits .max_keepalive_connections ,
10771063 keepalive_expiry = KEEPALIVE_EXPIRY ,
10781064 http2 = http2 ,
10791065 )
@@ -1094,20 +1080,17 @@ def _init_proxy_transport(
10941080 proxy_headers = proxy .headers .raw ,
10951081 proxy_mode = proxy .mode ,
10961082 ssl_context = ssl_context ,
1097- max_keepalive = limits .max_keepalive ,
10981083 max_connections = limits .max_connections ,
1084+ max_keepalive_connections = limits .max_keepalive_connections ,
10991085 keepalive_expiry = KEEPALIVE_EXPIRY ,
11001086 http2 = http2 ,
11011087 )
11021088
1103- def _transport_for_url (self , request : Request ) -> httpcore .AsyncHTTPTransport :
1089+ def _transport_for_url (self , url : URL ) -> httpcore .AsyncHTTPTransport :
11041090 """
11051091 Returns the transport instance that should be used for a given URL.
11061092 This will either be the standard connection pool, or a proxy.
11071093 """
1108- url = request .url
1109- enforce_http_url (request )
1110-
11111094 for pattern , transport in self ._proxies .items ():
11121095 if pattern .matches (url ):
11131096 return self ._transport if transport is None else transport
@@ -1245,7 +1228,7 @@ async def _send_single_request(
12451228 """
12461229 Sends a single request, without handling any redirections.
12471230 """
1248- transport = self ._transport_for_url (request )
1231+ transport = self ._transport_for_url (request . url )
12491232
12501233 with map_exceptions (HTTPCORE_EXC_MAP , request = request ):
12511234 (
0 commit comments