code: def process_extensions(
          headers: Headers,
          available_extensions: Optional[Sequence[ClientExtensionFactory]],
      ) -> List[Extension]:
          
          accepted_extensions: List[Extension] = []
  
          header_values = headers.get_all("Sec-WebSocket-Extensions")
  
          if header_values:
  
              if available_extensions is None:
                  raise InvalidHandshake("No extensions supported")
  
              parsed_header_values: List[ExtensionHeader] = sum(
                  [parse_extension(header_value) for header_value in header_values], []
              )
  
              for name, response_params in parsed_header_values:
  
                  for extension_factory in available_extensions:
  
                      # Skip non-matching extensions based on their name.
                      if extension_factory.name != name:
                          continue
  
                      # Skip non-matching extensions based on their params.
                      try:
                          extension = extension_factory.process_response_params(
                              response_params, accepted_extensions
                          )
                      except NegotiationError:
                          continue
  
                      # Add matching extension to the final list.
                      accepted_extensions.append(extension)
  
                      # Break out of the loop once we have a match.
                      break
  
                  # If we didn't break from the loop, no extension in our list
                  # matched what the server sent. Fail the connection.
                  else:
                      raise NegotiationError(
                          f"Unsupported extension: "
                          f"name = {name}, params = {response_params}"
                      )
  
          return accepted_extensions
docs: Handle the Sec-WebSocket-Extensions HTTP response header.
  
          Check that each extension is supported, as well as its parameters.
  
          Return the list of accepted extensions.
  
          Raise :exc:`~websockets.exceptions.InvalidHandshake` to abort the
          connection.
  
          :rfc:`6455` leaves the rules up to the specification of each
          :extension.
  
          To provide this level of flexibility, for each extension accepted by
          the server, we check for a match with each extension available in the
          client configuration. If no match is found, an exception is raised.
  
          If several variants of the same extension are accepted by the server,
          it may be configured severel times, which won't make sense in general.
          Extensions must implement their own requirements. For this purpose,
          the list of previously accepted extensions is provided.
  
          Other requirements, for example related to mandatory extensions or the
          order of extensions, may be implemented by overriding this method.