class WebSocket::Handshake::Handler::Server04

def handshake_keys

Other tags:
    See: WebSocket::Handshake::Handler::Base#handshake_keys -
def handshake_keys
  [
    %w[Upgrade websocket],
    %w[Connection Upgrade],
    ['Sec-WebSocket-Accept', signature]
  ] + protocol
end

def header_line

Other tags:
    See: WebSocket::Handshake::Handler::Base#header_line -
def header_line
  'HTTP/1.1 101 Switching Protocols'
end

def key

def key
  @handshake.headers['sec-websocket-key']
end

def protocol

def protocol
  return [] unless @handshake.headers.key?('sec-websocket-protocol')
  protos = @handshake.headers['sec-websocket-protocol'].split(/ *, */) & @handshake.protocols
  [['Sec-WebSocket-Protocol', protos.first]]
end

def signature

Returns:
  • (String) - signature
def signature
  return unless key
  string_to_sign = "#{key}258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
  [Digest::SHA1.digest(string_to_sign)].pack('m').chomp
end

def valid?

Other tags:
    See: WebSocket::Handshake::Base#valid? -
def valid?
  super && verify_key
end

def verify_key

def verify_key
  raise WebSocket::Error::Handshake::InvalidAuthentication unless key
  true
end