diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /testing/web-platform/tests/websockets/handlers | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/websockets/handlers')
-rw-r--r-- | testing/web-platform/tests/websockets/handlers/passive-close-abort_wsh.py | 24 | ||||
-rw-r--r-- | testing/web-platform/tests/websockets/handlers/remote-close_wsh.py | 44 |
2 files changed, 68 insertions, 0 deletions
diff --git a/testing/web-platform/tests/websockets/handlers/passive-close-abort_wsh.py b/testing/web-platform/tests/websockets/handlers/passive-close-abort_wsh.py new file mode 100644 index 0000000000..ac3f67c8db --- /dev/null +++ b/testing/web-platform/tests/websockets/handlers/passive-close-abort_wsh.py @@ -0,0 +1,24 @@ +# Copyright (c) 2024 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Wait for a Close frame from the client and then close the connection without +sending a Close frame in return. +""" + +from mod_pywebsocket.handshake import AbortedByUserException + + +def web_socket_do_extra_handshake(request): + pass + + +def web_socket_transfer_data(request): + while True: + if request.ws_stream.receive_message() is None: + return + + +def web_socket_passive_closing_handshake(request): + raise AbortedByUserException('abrupt close') diff --git a/testing/web-platform/tests/websockets/handlers/remote-close_wsh.py b/testing/web-platform/tests/websockets/handlers/remote-close_wsh.py new file mode 100644 index 0000000000..aadd99ea95 --- /dev/null +++ b/testing/web-platform/tests/websockets/handlers/remote-close_wsh.py @@ -0,0 +1,44 @@ +# Copyright (c) 2024 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Perform a server-initiated close according to the parameters passed in the +query string. Supported parameters: + + * code=INT: The close code to send in the close frame. If omitted the Close + frame will have an empty body. + + * reason=TEXT: The reason to be sent in the close frame. Only sent if `code` is + set. + + * abrupt=1: Close the connection without sending a Close frame. + +Example: /remote-close?code=1000&reason=Done + +""" + +import urllib + +from mod_pywebsocket.handshake import AbortedByUserException + + +def web_socket_do_extra_handshake(request): + pass + + +def web_socket_transfer_data(request): + parts = urllib.parse.urlsplit(request.uri) + parameters = urllib.parse.parse_qs(parts.query) + if 'abrupt' in parameters: + # Send a ping frame to make sure this isn't misinterpreted as a + # handshake failure. + request.ws_stream.send_ping('ping') + # Rudely close the connection. + raise AbortedByUserException('Abort the connection') + code = None + reason = None + if 'code' in parameters: + code = int(parameters['code'][0]) + reason = parameters.get('reason', [''])[0] + request.ws_stream.close_connection(code, reason) |