Path: redb-route/redb.Route.Http/HttpHeaderFilterStrategy.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Http/HttpHeaderFilterStrategy.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
namespace redb.Route.Http;
///
/// The default of the HTTP component, Apache Camel's HttpHeaderFilterStrategy.
/// An endpoint's headerFilterStrategy=#name replaces it; derive from it to add to it.
///
/// A producer () sends every exchange header but the component's control headers
/// () and empty values, and takes every response header back. A consumer
/// () takes every request header and answers with every exchange header but redb* and
/// Camel* ones and null values.
///
///
/// Whatever the strategy, the transport itself never carries the protocol fields (),
/// and a consumer never takes a received redbHttp.* header (it would pose as one the transport sets, such as
/// the remote address), never takes a response-only field from a request ()
/// and never answers with a value the request brought.
///
///
public class HttpHeaderFilterStrategy : IHeaderFilterStrategy
{
/// The default strategy of an HTTP producer.
public static HttpHeaderFilterStrategy Producer { get; } = new(EndpointRole.Producer);
/// The default strategy of an HTTP consumer.
public static HttpHeaderFilterStrategy Consumer { get; } = new(EndpointRole.Consumer);
/// Creates the default strategy of a producer or of a consumer.
/// Which side of the exchange the strategy serves.
public HttpHeaderFilterStrategy(EndpointRole role) => Role = role;
/// Which side of the exchange the strategy serves: a producer's request, or a consumer's response.
public EndpointRole Role { get; }
///
public virtual bool FilterOutgoing(string name, object? value, IExchange exchange)
=> Role == EndpointRole.Producer
? value is null || value.ToString() is not { Length: > 0 } || HttpHeaders.ControlHeaders.Contains(name)
: value is null
|| name.StartsWith("redb", StringComparison.OrdinalIgnoreCase)
|| name.StartsWith("Camel", StringComparison.OrdinalIgnoreCase);
///
public virtual bool FilterIncoming(string name, object? value, IExchange exchange) => false;
}