Repository: envoyproxy/envoy
File: source/extensions/filters/http/ext_proc/processor_state.h (C/C++)

Code before:
  };
  void setUntypedReceivingMetadataNamespaces(const std::vector<std::string>& ns) {
    untyped_receiving_namespaces_ = &ns;
  };

  bool sendHeaders() const { return send_headers_; }
  bool sendTrailers() const { return send_trailers_; }
  bool trailersSentToServer() const { return trailers_sent_to_server_; }
  void setTrailersSentToServer(bool b) { trailers_sent_to_server_ = b; }

  envoy::extensions::filters::http::ext_proc::v3::ProcessingMode_BodySendMode bodyMode() const {
    return body_mode_;
  }

  void setRequestHeaders(Http::RequestHeaderMap* headers) { request_headers_ = headers; }
  void setHeaders(Http::RequestOrResponseHeaderMap* headers) { headers_ = headers; }
  void setTrailers(Http::HeaderMap* trailers) { trailers_ = trailers; }
  const Http::RequestHeaderMap* requestHeaders() const { return request_headers_; };
  virtual const Http::RequestOrResponseHeaderMap* responseHeaders() const PURE;
  const Http::HeaderMap* responseTrailers() const { return trailers_; }

  void onStartProcessorCall(Event::TimerCb cb, std::chrono::milliseconds timeout,
                            CallbackState callback_state);
  void onFinishProcessorCall(Grpc::Status::GrpcStatus call_status,
                             CallbackState next_state = CallbackState::Idle,
                             bool continue_and_replace = false);
  void stopMessageTimer();
  bool restartMessageTimer(const uint32_t message_timeout_ms);

  // Idempotent methods for watermarking the body
  virtual void requestWatermark() PURE;
  virtual void clearWatermark() PURE;

  absl::Status handleHeadersResponse(const envoy::service::ext_proc::v3::HeadersResponse& response);

  /**
   * Handles responses containing body modifications from an external processor. Supports three
   * modes of operation: buffered, streamed, and buffered partial.
   *
   * @param response The body response received from the external processor
   * @return Status indicating success or failure of the handling operation
   */
  absl::Status handleBodyResponse(const envoy::service::ext_proc::v3::BodyResponse& response);

  absl::Status
  handleTrailersResponse(const envoy::service::ext_proc::v3::TrailersResponse& response);

  virtual const Buffer::Instance* bufferedData() const PURE;
  bool hasBufferedData() const { return bufferedData() != nullptr && bufferedData()->length() > 0; }
  virtual void addBufferedData(Buffer::Instance& data) const PURE;
  virtual void modifyBufferedData(std::function<void(Buffer::Instance&)> cb) const PURE;

Review comment (suggestion):
nit: given this function is only called in two places, we can just specify `continue_and_replace` on the caller site, instead of having default arg

Code after:
    return *typed_forwarding_namespaces_;
  };
  void setTypedForwardingMetadataNamespaces(const std::vector<std::string>& ns) {
    typed_forwarding_namespaces_ = &ns;
  };

  const std::vector<std::string>& untypedReceivingMetadataNamespaces() const {
    return *untyped_receiving_namespaces_;
  };
  void setUntypedReceivingMetadataNamespaces(const std::vector<std::string>& ns) {
    untyped_receiving_namespaces_ = &ns;
  };
  const std::vector<std::string>& untypedClusterMetadataForwardingNamespaces() const {
    return *untyped_cluster_metadata_forwarding_namespaces_;
  }
  void setUntypedClusterMetadataForwardingNamespaces(const std::vector<std::string>& ns) {
    untyped_cluster_metadata_forwarding_namespaces_ = &ns;
  }
  const std::vector<std::string>& typedClusterMetadataForwardingNamespaces() const {
    return *typed_cluster_metadata_forwarding_namespaces_;
  }
  void setTypedClusterMetadataForwardingNamespaces(const std::vector<std::string>& ns) {
    typed_cluster_metadata_forwarding_namespaces_ = &ns;
  }

  bool sendHeaders() const { return send_headers_; }
  bool sendTrailers() const { return send_trailers_; }
  bool trailersSentToServer() const { return trailers_sent_to_server_; }
  void setTrailersSentToServer(bool b) { trailers_sent_to_server_ = b; }

  envoy::extensions::filters::http::ext_proc::v3::ProcessingMode_BodySendMode bodyMode() const {
    return body_mode_;
  }

  void setRequestHeaders(Http::RequestHeaderMap* headers) { request_headers_ = headers; }
  void setHeaders(Http::RequestOrResponseHeaderMap* headers) { headers_ = headers; }
  void setTrailers(Http::HeaderMap* trailers) { trailers_ = trailers; }
  const Http::RequestHeaderMap* requestHeaders() const { return request_headers_; };
  virtual const Http::RequestOrResponseHeaderMap* responseHeaders() const PURE;
  const Http::HeaderMap* responseTrailers() const { return trailers_; }

  const absl::optional<MonotonicTime>& getCallStartTime() const { return call_start_time_; }
  void onStartProcessorCall(Event::TimerCb cb, std::chrono::milliseconds timeout,
                            CallbackState callback_state);
  void onFinishProcessorCall(Grpc::Status::GrpcStatus call_status,
                             CallbackState next_state = CallbackState::Idle);
  void stopMessageTimer();
  bool restartMessageTimer(const uint32_t message_timeout_ms);

  // Idempotent methods for watermarking the body
  virtual void requestWatermark() PURE;