/// implementation is recommended to implement the [`Drop`] trait to handle the necessary cleanup.
/// * `stream_handle` is the opaque handle to the HTTP stream (no longer valid after this call).
/// * `stream_handle` is the opaque handle to the HTTP stream (no longer valid after this call).
/// All the event hooks are called on the same thread as the one that the [`HttpFilter`] is created
/// via the [`HttpFilterConfig::new_http_filter`] method. In other words, the [`HttpFilter`] object
/// This must return [`abi::envoy_dynamic_module_type_on_http_filter_request_headers_status`] to
/// This must return [`abi::envoy_dynamic_module_type_on_http_filter_request_trailers_status`] to
/// This must return [`abi::envoy_dynamic_module_type_on_http_filter_response_headers_status`] to
/// This must return [`abi::envoy_dynamic_module_type_on_http_filter_response_trailers_status`] to
/// * `response_headers` is a list of key-value pairs of the response headers. This is optional.
/// * `stream_handle` is the opaque handle to the HTTP stream (no longer valid after this call).
/// * `stream_handle` is the opaque handle to the HTTP stream (no longer valid after this call).
/// An opaque object that represents the underlying Envoy Http filter config. This has one to one
/// This can be used to schedule an event to the main thread where the filter config is running.
/// add a custom flag to indicate a noteworthy event of this stream. Mutliple flags could be added
/// and will be concatenated with comma. It should not contain any empty or space characters (' ',
/// Append a number value to the dynamic metadata list stored under the given namespace and key.
/// Append a string value to the dynamic metadata list stored under the given namespace and key.
fn add_dynamic_metadata_list_string(&mut self, namespace: &str, key: &str, value: &str) -> bool;
/// Get the number value at the given index in the metadata list stored under the given namespace
/// Get the string value at the given index in the metadata list stored under the given namespace
/// Returns true if the operation is successful. This can fail if no ObjectFactory is registered
/// Get the serialized value of a typed filter state object with the given key. The object must
/// [`EnvoyBuffer`] from the vector has no effect on the underlying Envoy buffer. To write beyond
/// the end of the buffer, use [`EnvoyHttpFilter::append_received_request_body`]. To remove data
/// size of the buffer, and then use [`EnvoyHttpFilter::append_received_request_body`] to write
/// Similar to [`EnvoyHttpFilter::get_received_request_body`], but returns the buffered request
/// Similar to [`EnvoyHttpFilter::get_received_request_body_size`], but returns the size of the
/// modified in place. However, the buffer itself is immutable. For example, adding or removing
/// To write completely new data, use [`EnvoyHttpFilter::drain_received_response_body`] for the
/// size of the buffer, and then use [`EnvoyHttpFilter::append_received_response_body`] to write
/// Similar to [`EnvoyHttpFilter::get_received_response_body`], but returns the buffered response
/// Similar to [`EnvoyHttpFilter::get_received_response_body_size`], but returns the size of the
/// Returns true if the latest received response body is the previously buffered response body.
/// * `stream_handle` must be a valid handle returned from [`EnvoyHttpFilter::start_http_stream`].
/// * `stream_handle` must be a valid handle returned from [`EnvoyHttpFilter::start_http_stream`].
/// * `stream_handle` must be a valid handle returned from [`EnvoyHttpFilter::start_http_stream`].
fn spawn_child_span<'a>(&'a self, operation_name: &str) -> Option<Box<dyn EnvoyChildSpan + 'a>>;
/// * `host` - The host address to override (e.g., "10.0.0.1:8080"). Must be a valid IP address.
/// * `strict` - If true, the request will fail if the override host is not available. If false,
/// Returns `true` if the override was set successfully, `false` if the host address is invalid.
/// This is a connection-level operation that affects all streams on the connection. When called,
/// the current filter chain iteration is aborted immediately and no subsequent filters will be
/// - **HTTP/2**: Sends an actual GOAWAY frame to notify the client that the connection is being
/// - **HTTP/1**: Since HTTP/1 does not have a GOAWAY frame, the connection is closed directly.
/// The `graceful` parameter still controls whether in-flight requests are allowed to complete.
/// * `graceful` - If true, initiates a graceful drain sequence that allows in-flight streams to
/// Multiple calls to this method are safe and the operation is idempotent. Subsequent calls are
/// After calling this function successfully, the current filter chain will be destroyed and a new
/// stream will be created. The filter should return StopIteration from the current event hook.
/// Returns `true` if the stream recreation was initiated successfully, `false` otherwise (e.g.,
/// This is a subset of [`EnvoyHttpFilter::clear_route_cache`]. Use this when a filter modifies
/// headers that affect cluster selection but not the route itself. This is more efficient than
fn add_dynamic_metadata_list_number(&mut self, namespace: &str, key: &str, value: f64) -> bool {
fn add_dynamic_metadata_list_string(&mut self, namespace: &str, key: &str, value: &str) -> bool {
fn add_dynamic_metadata_list_bool(&mut self, namespace: &str, key: &str, value: bool) -> bool {
unsafe { abi::envoy_dynamic_module_callback_http_received_buffered_request_body(self.raw_ptr) }
unsafe { abi::envoy_dynamic_module_callback_http_received_buffered_response_body(self.raw_ptr) }
let raw_ptr = unsafe { abi::envoy_dynamic_module_callback_http_get_active_span(self.raw_ptr) };
fn spawn_child_span<'a>(&'a self, operation_name: &str) -> Option<Box<dyn EnvoyChildSpan + 'a>> {
let span_ptr = unsafe { abi::envoy_dynamic_module_callback_http_get_active_span(self.raw_ptr) };
/// This represents a thin thread-safe object that can be used to schedule a generic event to the
/// For example, this can be used to offload some blocking work from the HTTP filter processing
/// This implements the [`EnvoyHttpFilterScheduler`] trait with the given raw pointer to the Envoy
let config_slice = unsafe { std::slice::from_raw_parts(config.ptr as *const _, config.length) };
let config_slice = unsafe { std::slice::from_raw_parts(config.ptr as *const _, config.length) };
Some(unsafe { std::slice::from_raw_parts(body_chunks as *const EnvoyBuffer, body_chunks_size) })
pub unsafe extern "C" fn envoy_dynamic_module_on_http_filter_downstream_above_write_buffer_high_watermark(
filter.on_downstream_above_write_buffer_high_watermark(&mut EnvoyHttpFilterImpl::new(envoy_ptr));
pub unsafe extern "C" fn envoy_dynamic_module_on_http_filter_downstream_below_write_buffer_low_watermark(
filter.on_downstream_below_write_buffer_low_watermark(&mut EnvoyHttpFilterImpl::new(envoy_ptr));
Some(unsafe { std::slice::from_raw_parts(body_chunks as *const EnvoyBuffer, body_chunks_size) })