header-continuation_wsh.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. # Copyright 2015 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. # The purpose of this test is to verify that WebSocket supports header
  6. # continuations, as deprecated in RFC7230 section 3.2.4.
  7. # It is used by test case WebSocketEndToEndTest.HeaderContinuations.
  8. from mod_pywebsocket import handshake
  9. from mod_pywebsocket.handshake.hybi import compute_accept_from_unicode
  10. def web_socket_do_extra_handshake(request):
  11. accept = compute_accept_from_unicode(request.headers_in['Sec-WebSocket-Key'])
  12. message = (b'HTTP/1.1 101 Switching Protocols\r\n'
  13. b'Upgrade: websocket\r\n'
  14. b'Connection: Upgrade\r\n'
  15. b'Sec-WebSocket-Accept: %s\r\n'
  16. b'Sec-WebSocket-Extensions: permessage-deflate;\r\n'
  17. b' server_max_window_bits=10\r\n'
  18. b'\r\n' % accept)
  19. request.connection.write(message)
  20. # Prevent pywebsocket from sending its own handshake message.
  21. raise handshake.AbortedByUserException('Close the connection')
  22. def web_socket_transfer_data(request):
  23. pass