summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/websockets/handlers/wrong_accept_key_wsh.py
blob: 43240e1afb6126ed9e6cdacd50d7f8b95fcc9358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python

import sys, urllib, time


def web_socket_do_extra_handshake(request):
    msg = (b'HTTP/1.1 101 Switching Protocols:\x0D\x0A'
           b'Connection: Upgrade\x0D\x0A'
           b'Upgrade: WebSocket\x0D\x0A'
           b'Sec-WebSocket-Origin: %s\x0D\x0A'
           b'Sec-WebSocket-Accept: thisisawrongacceptkey\x0D\x0A\x0D\x0A') % request.ws_origin.encode('UTF-8')
    request.connection.write(msg)
    return


def web_socket_transfer_data(request):
    while True:
        request.ws_stream.send_message('test', binary=False)
        return