The server (response) handshake for a WebSocket
opening handshake.
Create a server handshake frame from the given client handshake
.
# File lib/mongrel2/websocket.rb, line 271
def self::from_request( handshake )
self.log.debug "Creating the server handshake for client handshake %p" % [ handshake ]
response = super
response.body.truncate( 0 )
# Mongrel2 puts the negotiated key in the body of the request
response.headers.sec_websocket_accept = handshake.body.read
# Set up the other typical server handshake values
response.status = HTTP::SWITCHING_PROTOCOLS
response.header.upgrade = 'websocket'
response.header.connection = 'Upgrade'
return response
end
The list of protocols in the handshake's Sec-WebSocket-Protocol header as an Array of Strings.
# File lib/mongrel2/websocket.rb, line 290
def protocols
return ( self.headers.sec_websocket_protocol || '' ).split( /\s*,\s*/ )
end
Set the list of protocols in the handshake's Sec-WebSocket-Protocol header.
# File lib/mongrel2/websocket.rb, line 296
def protocols=( new_protocols )
value = Array( new_protocols ).join( ', ' )
self.headers.sec_websocket_protocol = value
end