def on_response_headers()

in callouts/python/extproc/example/add_custom_response/service_callout_example.py [0:0]


  def on_response_headers(
      self, headers: service_pb2.HttpHeaders,
      context: ServicerContext):
    """Custom processor on response headers.

        Args:
          headers (service_pb2.HttpHeaders): The HTTP headers received in the response.
          context (ServicerContext): The context object for the gRPC service.

        Returns:
          service_pb2.HeadersResponse: The response containing the mutations to be applied
          to the response headers.
        """
    if callout_tools.headers_contain(headers, "bad-header"):
      callout_tools.deny_callout(context)
    if callout_tools.headers_contain(headers, "mock"):
      return generate_mock_header_response()
    return callout_tools.add_header_mutation(add=[('header-response',
                                                   'response')])