def server_extensions_handshake(requested, supported):<EOL>
accepts = {}<EOL>for offer in requested:<EOL><INDENT>name = offer.split("<STR_LIT:;>", <NUM_LIT:1>)[<NUM_LIT:0>].strip()<EOL>for extension in supported:<EOL><INDENT>if extension.name == name:<EOL><INDENT>accept = extension.accept(offer)<EOL>if accept is True:<EOL><INDENT>accepts[extension.name] = True<EOL><DEDENT>elif accept is not False and accept is not None:<EOL><INDENT>accepts[extension.name] = accept.encode("<STR_LIT:ascii>")<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if accepts:<EOL><INDENT>extensions = []<EOL>for name, params in accepts.items():<EOL><INDENT>if params is True:<EOL><INDENT>extensions.append(name.encode("<STR_LIT:ascii>"))<EOL><DEDENT>else:<EOL><INDENT>params = params.decode("<STR_LIT:ascii>")<EOL>if params == "<STR_LIT>":<EOL><INDENT>extensions.append(("<STR_LIT:%s>" % (name)).encode("<STR_LIT:ascii>"))<EOL><DEDENT>else:<EOL><INDENT>extensions.append(("<STR_LIT>" % (name, params)).encode("<STR_LIT:ascii>"))<EOL><DEDENT><DEDENT><DEDENT>return b"<STR_LIT:U+002CU+0020>".join(extensions)<EOL><DEDENT>return None<EOL>
Agree on the extensions to use returning an appropriate header value.

    This returns None if there are no agreed extensions