'Returns the origin of a WebSocket connect message.
Raises DenyConnection for messages with missing or non-ascii Origin
header.'

def get_origin(self, message):

    try:
        header = self.get_header(message, 'origin')[0]
    except (IndexError, KeyError):
        raise DenyConnection
    try:
        origin = header.decode('ascii')
    except UnicodeDecodeError:
        raise DenyConnection
    return origin
