protocol-test_wsh.py 628 B

123456789101112131415161718192021
  1. # Copyright (c) 2012 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. from mod_pywebsocket import msgutil
  5. from six.moves.urllib import parse
  6. def web_socket_do_extra_handshake(request):
  7. r = request.ws_resource.split('?', 1)
  8. if len(r) == 1:
  9. return
  10. param = parse.parse_qs(r[1])
  11. if 'protocol' in param:
  12. request.ws_protocol = param['protocol'][0]
  13. def web_socket_transfer_data(request):
  14. msgutil.send_message(request, request.ws_protocol)
  15. # Wait for a close message.
  16. unused = request.ws_stream.receive_message()