passive-close-abort_wsh.py (633B)
1 # Copyright (c) 2024 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 """ 6 Wait for a Close frame from the client and then close the connection without 7 sending a Close frame in return. 8 """ 9 10 from pywebsocket3.handshake import AbortedByUserException 11 12 13 def web_socket_do_extra_handshake(request): 14 pass 15 16 17 def web_socket_transfer_data(request): 18 while True: 19 if request.ws_stream.receive_message() is None: 20 return 21 22 23 def web_socket_passive_closing_handshake(request): 24 raise AbortedByUserException('abrupt close')