Skip to content

Commit 65400cb

Browse files
authored
Use correct port for wss URLs when ssl_context is None (#197)
Prior to 49b93c1, `_url_to_host()` modified `ssl_context` according to whether the URL contained `ws` or `wss`. That commit introduced `return_ssl_context` because the return value has a different type set (`ssl.SSLContext | bool`) than the passed in argument (`ssl.SSLContext | None`). But the determination of which port number to use was still based on `ssl_context`, which would result in port 80 being used in the case where the user passed in a `wss://` URL without an SSLContext. Checking `return_ssl_context` instead results in the correct behavior.
1 parent ccd2c88 commit 65400cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

trio_websocket/_impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def _url_to_host(
518518
if parts.port is not None:
519519
port = parts.port
520520
else:
521-
port = 443 if ssl_context else 80
521+
port = 443 if return_ssl_context else 80
522522
path_qs = parts.path
523523
# RFC 7230, Section 5.3.1:
524524
# If the target URI's path component is empty, the client MUST

0 commit comments

Comments
 (0)