def server_extensions_handshake(requested: List[str], supported: List[Extension]) -> Optional[bytes]:
    'Agree on the extensions to use returning an appropriate header value.\n\n    This returns None if there are no agreed extensions\n    '
    accepts: Dict[(str, Union[(bool, bytes)])] = {}
    for offer in requested:
        name = offer.split(';', 1)[0].strip()
        for extension in supported:
            if (extension.name == name):
                accept = extension.accept(offer)
                if (accept is True):
                    accepts[extension.name] = True
                elif ((accept is not False) and (accept is not None)):
                    accepts[extension.name] = accept.encode('ascii')
    if accepts:
        extensions: List[bytes] = []
        for (name, params) in accepts.items():
            name = name.encode('ascii')
            if (params is True):
                extensions.append(name)
            elif (params == b''):
                extensions.append((b'%s' % name))
            else:
                extensions.append((b'%s; %s' % (name, params)))
        return b', '.join(extensions)
    return None
Agree on the extensions to use returning an appropriate header value.

This returns None if there are no agreed extensions
def server_extensions_handshake(requested: List[str], supported: List[Extension]) -> Optional[bytes]:
    'Agree on the extensions to use returning an appropriate header value.\n\n    This returns None if there are no agreed extensions\n    '
    accepts: Dict[(str, Union[(bool, bytes)])] = {}
    for offer in requested:
        name = offer.split(';', 1)[0].strip()
        for extension in supported:
            if (extension.name == name):
                accept = extension.accept(offer)
                if (accept is True):
                    accepts[extension.name] = True
                elif ((accept is not False) and (accept is not None)):
                    accepts[extension.name] = accept.encode('ascii')
    if accepts:
        extensions: List[bytes] = []
        for (name, params) in accepts.items():
            name = name.encode('ascii')
            if (params is True):
                extensions.append(name)
            elif (params == b):
                extensions.append((b'%s' % name))
            else:
                extensions.append((b'%s; %s' % (name, params)))
        return b', '.join(extensions)
    return None