mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
25
tests/wpt/web-platform-tests/websockets/handlers/echo_wsh.py
Executable file
25
tests/wpt/web-platform-tests/websockets/handlers/echo_wsh.py
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/python
|
||||
from mod_pywebsocket import msgutil
|
||||
|
||||
_GOODBYE_MESSAGE = u'Goodbye'
|
||||
|
||||
def web_socket_do_extra_handshake(request):
|
||||
# This example handler accepts any request. See origin_check_wsh.py for how
|
||||
# to reject access from untrusted scripts based on origin value.
|
||||
if request.ws_requested_protocols:
|
||||
if "echo" in request.ws_requested_protocols:
|
||||
request.ws_protocol = "echo"
|
||||
|
||||
|
||||
def web_socket_transfer_data(request):
|
||||
while True:
|
||||
line = request.ws_stream.receive_message()
|
||||
if line is None:
|
||||
return
|
||||
if isinstance(line, unicode):
|
||||
request.ws_stream.send_message(line, binary=False)
|
||||
if line == _GOODBYE_MESSAGE:
|
||||
return
|
||||
else:
|
||||
request.ws_stream.send_message(line, binary=True)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue