41
41
JsonValue = None | bool | int | float | str | list ["JsonValue" ] | dict [str , "JsonValue" ]
42
42
43
43
44
- def request (method , url , * , read_limit = None , ** kwargs ):
44
+ def request (method : str , url : str , * , read_limit : int | None = None , ** kwargs ) -> "Response" :
45
45
"""Request performs an HTTP request and reads the entire response body.
46
46
47
47
:param str method: HTTP method to request (e.g. 'GET', 'POST')
@@ -425,11 +425,11 @@ def _prepare_request(
425
425
"""Parses the URL, returns the path and the right HTTPConnection subclass."""
426
426
parsed_url = urllib .parse .urlparse (url )
427
427
428
- is_unix = unix_socket is not None
429
428
scheme = parsed_url .scheme .lower ()
430
429
if scheme .endswith ("+unix" ):
431
430
scheme = scheme [:- 5 ]
432
- is_unix = True
431
+ if unix_socket is None :
432
+ unix_socket = urllib .parse .unquote (parsed_url .netloc )
433
433
if scheme == "https" :
434
434
raise ValueError ("https+unix is not implemented" )
435
435
@@ -444,9 +444,6 @@ def _prepare_request(
444
444
if parsed_url .port :
445
445
port = parsed_url .port
446
446
447
- if is_unix and unix_socket is None :
448
- unix_socket = urllib .parse .unquote (parsed_url .netloc )
449
-
450
447
path = parsed_url .path
451
448
if parsed_url .query :
452
449
if enc_params :
@@ -462,7 +459,7 @@ def _prepare_request(
462
459
source_address = (source_address , 0 )
463
460
464
461
conn : HTTPConnection | UnixHTTPConnection | HTTPSConnection
465
- if is_unix :
462
+ if unix_socket is not None :
466
463
conn = UnixHTTPConnection (unix_socket , timeout = timeout )
467
464
elif is_https :
468
465
if ssl_context is None :
0 commit comments