1*6777b538SAndroid Build Coastguard Worker# Copyright 2015 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker# found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Workerfrom mod_pywebsocket import handshake 6*6777b538SAndroid Build Coastguard Worker 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Workerdef web_socket_do_extra_handshake(request): 9*6777b538SAndroid Build Coastguard Worker msg = (b'HTTP/1.1 101 Switching Protocols\r\n' 10*6777b538SAndroid Build Coastguard Worker b'Upgrade: websocket\r\n' 11*6777b538SAndroid Build Coastguard Worker b'Connection: Upgrade\r\n' 12*6777b538SAndroid Build Coastguard Worker b'Sec-WebSocket-Accept: 3rfd') 13*6777b538SAndroid Build Coastguard Worker request.connection.write(msg) 14*6777b538SAndroid Build Coastguard Worker # Prevent pywebsocket from sending its own handshake message. 15*6777b538SAndroid Build Coastguard Worker raise handshake.AbortedByUserException('Close the connection') 16*6777b538SAndroid Build Coastguard Worker 17*6777b538SAndroid Build Coastguard Worker 18*6777b538SAndroid Build Coastguard Workerdef web_socket_transfer_data(request): 19*6777b538SAndroid Build Coastguard Worker pass 20