| OLD | NEW |
| 1 import struct | 1 import struct |
| 2 import time | 2 import time |
| 3 from mod_pywebsocket import common | 3 from mod_pywebsocket import common |
| 4 | 4 |
| 5 | 5 |
| 6 def web_socket_do_extra_handshake(request): | 6 def web_socket_do_extra_handshake(request): |
| 7 pass | 7 pass |
| 8 | 8 |
| 9 | 9 |
| 10 def web_socket_transfer_data(request): | 10 def web_socket_transfer_data(request): |
| 11 length = 0x8000000000000000 | 11 length = 0x8000000000000000 |
| 12 | 12 |
| 13 # pywebsocket refuses to send a frame with too long payload. | 13 # pywebsocket refuses to send a frame with too long payload. |
| 14 # Thus, we need to build a frame manually. | 14 # Thus, we need to build a frame manually. |
| 15 header = chr(0x80 | common.OPCODE_TEXT) # 0x80 is for "fin" bit. | 15 header = chr(0x80 | common.OPCODE_TEXT) # 0x80 is for "fin" bit. |
| 16 header += chr(127) | 16 header += chr(127) |
| 17 header += struct.pack('!Q', length) | 17 header += struct.pack('!Q', length) |
| 18 request.connection.write(header) | 18 request.connection.write(header) |
| 19 | 19 |
| 20 # Send data indefinitely to simulate a real (broken) server sending a big fr
ame. | 20 # Send data indefinitely to simulate a real (broken) server sending a big fr
ame. |
| 21 # A client should ignore these bytes and abort the connection. | 21 # A client should ignore these bytes and abort the connection. |
| 22 while True: | 22 while True: |
| 23 request.connection.write('X' * 4096) | 23 request.connection.write('X' * 4096) |
| 24 time.sleep(1) | 24 time.sleep(1) |
| OLD | NEW |