From 953e398d69694d597034891d88af921798a4fb7d Mon Sep 17 00:00:00 2001 From: bsnych <122523292+bsnych@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:18:08 +0300 Subject: [PATCH 1/2] Added missing "reason" to ensure backward compatibility Reason added for Informational response to socket connection upgrade. This ensures backwards compatibility for older socket libraries like: OCaml/websokets --- src/wsproto/handshake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wsproto/handshake.py b/src/wsproto/handshake.py index 72af722..a79bf07 100644 --- a/src/wsproto/handshake.py +++ b/src/wsproto/handshake.py @@ -286,7 +286,7 @@ def _accept(self, event: AcceptConnection) -> bytes: headers.append((b"Sec-WebSocket-Extensions", accepts)) response = h11.InformationalResponse( - status_code=101, headers=headers + event.extra_headers + status_code=101, headers=headers + event.extra_headers, reason=b"Switching Protocols" ) self._connection = Connection( ConnectionType.CLIENT if self.client else ConnectionType.SERVER, From 6024a40a3e12e63ef7d1daa1ca98046abfbecf0d Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Thu, 1 May 2025 16:07:54 +0200 Subject: [PATCH 2/2] linting --- src/wsproto/handshake.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wsproto/handshake.py b/src/wsproto/handshake.py index a79bf07..28b0d8c 100644 --- a/src/wsproto/handshake.py +++ b/src/wsproto/handshake.py @@ -286,7 +286,9 @@ def _accept(self, event: AcceptConnection) -> bytes: headers.append((b"Sec-WebSocket-Extensions", accepts)) response = h11.InformationalResponse( - status_code=101, headers=headers + event.extra_headers, reason=b"Switching Protocols" + status_code=101, + headers=headers + event.extra_headers, + reason=b"Switching Protocols", ) self._connection = Connection( ConnectionType.CLIENT if self.client else ConnectionType.SERVER,