@@ -311,10 +311,10 @@ def __init__(
311
311
if create_connection is None :
312
312
create_connection = ClientConnection
313
313
314
- def protocol_factory (wsuri : WebSocketURI ) -> ClientConnection :
314
+ def protocol_factory (uri : WebSocketURI ) -> ClientConnection :
315
315
# This is a protocol in the Sans-I/O implementation of websockets.
316
316
protocol = ClientProtocol (
317
- wsuri ,
317
+ uri ,
318
318
origin = origin ,
319
319
extensions = extensions ,
320
320
subprotocols = subprotocols ,
@@ -346,15 +346,15 @@ async def create_connection(self) -> ClientConnection:
346
346
"""Create TCP or Unix connection."""
347
347
loop = asyncio .get_running_loop ()
348
348
349
- wsuri = parse_uri (self .uri )
349
+ ws_uri = parse_uri (self .uri )
350
350
kwargs = self .connection_kwargs .copy ()
351
351
352
352
def factory () -> ClientConnection :
353
- return self .protocol_factory (wsuri )
353
+ return self .protocol_factory (ws_uri )
354
354
355
- if wsuri .secure :
355
+ if ws_uri .secure :
356
356
kwargs .setdefault ("ssl" , True )
357
- kwargs .setdefault ("server_hostname" , wsuri .host )
357
+ kwargs .setdefault ("server_hostname" , ws_uri .host )
358
358
if kwargs .get ("ssl" ) is None :
359
359
raise ValueError ("ssl=None is incompatible with a wss:// URI" )
360
360
else :
@@ -365,8 +365,8 @@ def factory() -> ClientConnection:
365
365
_ , connection = await loop .create_unix_connection (factory , ** kwargs )
366
366
else :
367
367
if kwargs .get ("sock" ) is None :
368
- kwargs .setdefault ("host" , wsuri .host )
369
- kwargs .setdefault ("port" , wsuri .port )
368
+ kwargs .setdefault ("host" , ws_uri .host )
369
+ kwargs .setdefault ("port" , ws_uri .port )
370
370
_ , connection = await loop .create_connection (factory , ** kwargs )
371
371
return connection
372
372
@@ -392,9 +392,9 @@ def process_redirect(self, exc: Exception) -> Exception | str:
392
392
):
393
393
return exc
394
394
395
- old_wsuri = parse_uri (self .uri )
395
+ old_ws_uri = parse_uri (self .uri )
396
396
new_uri = urllib .parse .urljoin (self .uri , exc .response .headers ["Location" ])
397
- new_wsuri = parse_uri (new_uri )
397
+ new_ws_uri = parse_uri (new_uri )
398
398
399
399
# If connect() received a socket, it is closed and cannot be reused.
400
400
if self .connection_kwargs .get ("sock" ) is not None :
@@ -403,14 +403,14 @@ def process_redirect(self, exc: Exception) -> Exception | str:
403
403
)
404
404
405
405
# TLS downgrade is forbidden.
406
- if old_wsuri .secure and not new_wsuri .secure :
406
+ if old_ws_uri .secure and not new_ws_uri .secure :
407
407
return SecurityError (f"cannot follow redirect to non-secure URI { new_uri } " )
408
408
409
409
# Apply restrictions to cross-origin redirects.
410
410
if (
411
- old_wsuri .secure != new_wsuri .secure
412
- or old_wsuri .host != new_wsuri .host
413
- or old_wsuri .port != new_wsuri .port
411
+ old_ws_uri .secure != new_ws_uri .secure
412
+ or old_ws_uri .host != new_ws_uri .host
413
+ or old_ws_uri .port != new_ws_uri .port
414
414
):
415
415
# Cross-origin redirects on Unix sockets don't quite make sense.
416
416
if self .connection_kwargs .get ("unix" , False ):
0 commit comments