|
Lines 1-5
a/LayoutTests/http/tests/websocket/tests/hybi/client-close_wsh.py_sec1
|
| 1 |
from mod_pywebsocket import msgutil |
1 |
import struct |
| 2 |
|
2 |
|
|
|
3 |
from mod_pywebsocket import msgutil |
| 4 |
from mod_pywebsocket import stream |
| 3 |
|
5 |
|
| 4 |
def web_socket_do_extra_handshake(request): |
6 |
def web_socket_do_extra_handshake(request): |
| 5 |
pass |
7 |
pass |
|
Lines 9-17
def web_socket_transfer_data(request):
a/LayoutTests/http/tests/websocket/tests/hybi/client-close_wsh.py_sec2
|
| 9 |
# Wait for a close frame sent from the client. |
11 |
# Wait for a close frame sent from the client. |
| 10 |
close_frame = request.ws_stream.receive_bytes(6) |
12 |
close_frame = request.ws_stream.receive_bytes(6) |
| 11 |
|
13 |
|
|
|
14 |
msgutil.send_message(request, 'Client should ignore this message') |
| 15 |
|
| 12 |
# Send only first two bytes of the received frame. The remaining four bytes are |
16 |
# Send only first two bytes of the received frame. The remaining four bytes are |
| 13 |
# "masking key", which changes every time the test runs. |
17 |
# "masking key", which changes every time the test runs. |
| 14 |
msgutil.send_message(request, 'close_frame[:2]=%r' % close_frame[:2]) |
18 |
data = struct.pack('!H', 1000) + 'close_frame[:2]=%r' % close_frame[:2] |
|
|
19 |
request.connection.write(stream.create_close_frame(data)) |
| 15 |
|
20 |
|
| 16 |
# If the following assertion fails, AssertionError will be raised, |
21 |
# If the following assertion fails, AssertionError will be raised, |
| 17 |
# which will prevent pywebsocket from sending a close frame. |
22 |
# which will prevent pywebsocket from sending a close frame. |