(self, headers)
return protocols, extensions
Read the upgrade handshake's response headers and
        validate them against :rfc:`6455`.
Read the upgrade handshake's response headers and
        validate them against :rfc:`6455`.
Read the upgrade handshake s response headers and validate them against : rfc : 6455 .
def process_handshake_header(self, headers):
        """
        Read the upgrade handshake's response headers and
        validate them against :rfc:`6455`.
        """
        protocols = []
        extensions = []

        headers = headers.strip()

        for header_line in headers.split(enc('\r\n')):
            header, value = header_line.split(enc(':'), 1)
            header = header.strip().lower()
            value = value.strip().lower()

            if header == 'upgrade' and value != 'websocket':
                raise HandshakeError("Invalid Upgrade header: %s" % value)

            elif header == 'connection' and value != 'upgrade':
                raise HandshakeError("Invalid Connection header: %s" % value)

            elif header == 'sec-websocket-accept':
                match = b64encode(sha1(enc(self.key + WS_KEY)).digest())
                if value != match.lower():
                    raise HandshakeError("Invalid challenge response: %s" % value)

            elif header == 'sec-websocket-protocol':
                protocols = ','.join(value)

            elif header == 'sec-websocket-extensions':
                extensions = ','.join(value)

        return protocols, extensions
def process_handshake_header ( self , headers ) : protocols = [ ] extensions = [ ] headers = headers . strip ( ) for header_line in headers . split ( enc ( '\r\n' ) ) : header , value = header_line . split ( enc ( ':' ) , 1 ) header = header . strip ( ) . lower ( ) value = value . strip ( ) . lower ( ) if header == 'upgrade' and value != 'websocket' : raise HandshakeError ( "Invalid Upgrade header: %s" % value ) elif header == 'connection' and value != 'upgrade' : raise HandshakeError ( "Invalid Connection header: %s" % value ) elif header == 'sec-websocket-accept' : match = b64encode ( sha1 ( enc ( self . key + WS_KEY ) ) . digest ( ) ) if value != match . lower ( ) : raise HandshakeError ( "Invalid challenge response: %s" % value ) elif header == 'sec-websocket-protocol' : protocols = ',' . join ( value ) elif header == 'sec-websocket-extensions' : extensions = ',' . join ( value ) return protocols , extensions