code: def server_extensions_handshake(requested, supported):
      # type: (List[str], List[Extension]) -> Optional[bytes]
      
      accepts = {}
      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 = []
          for name, params in accepts.items():
              if params is True:
                  extensions.append(name.encode("ascii"))
              else:
                  # py34 annoyance: doesn't support bytestring formatting
                  params = params.decode("ascii")
                  if params == "":
                      extensions.append(("%s" % (name)).encode("ascii"))
                  else:
                      extensions.append(("%s; %s" % (name, params)).encode("ascii"))
          return b", ".join(extensions)
  
      return None
docs: Agree on the extensions to use returning an appropriate header value.
  
      This returns None if there are no agreed extensions