Path: redb-route/redb.Route.As2/As2Headers.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.As2/As2Headers.cs
----
namespace redb.Route.As2;
///
/// AS2 header names surfaced on the exchange, and the reserved set that must not be blindly bridged.
///
/// Two planes, deliberately: AS2 wire headers keep their verbatim names (AS2-From, ...),
/// while redb-computed metadata (MIC, signature validity, ...) lives under the .
/// Canonical-plane rule (from the IBM MQ usr-folder decision): each header has ONE source of truth and the
/// consumer and producer never disagree. The load-bearing example is Content-Type — the transport
/// value is the multipart/signed wrapper; the business payload's real content type lives on
/// Message.ContentType.
///
///
public static class As2Headers
{
/// Prefix for redb-computed AS2 metadata headers.
public const string Prefix = "redbAs2.";
// ── AS2 wire headers (verbatim names; constants for explicit set/get) ────
/// Sender AS2 identifier.
public const string As2From = "AS2-From";
/// Recipient AS2 identifier.
public const string As2To = "AS2-To";
/// AS2 protocol version.
public const string As2Version = "AS2-Version";
/// Unique message id; echoed back in the MDN as Original-Message-ID.
public const string MessageId = "Message-ID";
/// Human-readable subject.
public const string Subject = "Subject";
/// Requests an MDN and (for async) where to send it.
public const string DispositionNotificationTo = "Disposition-Notification-To";
/// Requested MDN profile (signed-receipt protocol / micalg).
public const string DispositionNotificationOptions = "Disposition-Notification-Options";
/// URL for an asynchronous MDN (present ⇒ async).
public const string ReceiptDeliveryOption = "Receipt-Delivery-Option";
// ── redb-computed metadata (under Prefix) ────────────────────────────────
/// Computed Message Integrity Check value.
public const string Mic = Prefix + "mic";
/// MIC digest algorithm.
public const string MicAlg = Prefix + "micalg";
/// Resolved partner (connection-factory) name.
public const string PartnerName = Prefix + "partner";
///
/// True only when a signature was present and verified against the partner certificate; false for an
/// unsigned message or MDN, where nothing was verified.
///
public const string SignatureValid = Prefix + "signatureValid";
/// Remote peer address.
public const string RemoteAddress = Prefix + "remoteAddress";
/// MDN disposition outcome.
public const string MdnDisposition = Prefix + "mdnDisposition";
///
/// True only when the MDN's Received-Content-MIC was compared with the MIC we sent and is the same; false when it
/// differs, is absent, or there was nothing to compare it with (see ).
///
public const string MdnMicMatch = Prefix + "mdnMicMatch";
///
/// The outcome of the MIC comparison: matched, mismatch, absent (the MDN carries no
/// Received-Content-MIC) or unknown (the MDN names no message we are waiting for: no Original-Message-ID,
/// or one sent before a restart, evicted after the correlation TTL, or sent by another node).
///
public const string MdnMicStatus = Prefix + "mdnMicStatus";
///
/// True when the MDN confirms the transfer: its disposition is positive, its MIC matched, and its signature is
/// valid where the agreement asks for a signed MDN. The one header to branch on for "delivered and verified".
///
public const string MdnConfirmed = Prefix + "mdnConfirmed";
/// True if the header name is a redb AS2 metadata header (must not be bridged onto the wire).
public static bool IsRedbHeader(string key)
=> key.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase);
///
/// Headers the producer must NOT blindly copy from exchange.In.Headers onto the outgoing message:
/// MIME headers we set explicitly through the content object, AS2 semantics we set from partner config,
/// and HTTP hop-by-hop headers. redb metadata is filtered separately via .
///
internal static readonly HashSet NonBridgedHeaders = new(StringComparer.OrdinalIgnoreCase)
{
// MIME headers set explicitly via the content object
"Content-Type", "Content-Disposition", "Content-Transfer-Encoding", "Content-Length", "Content-Encoding",
// AS2 semantics set from partner config
"AS2-From", "AS2-To", "AS2-Version", "Message-ID",
"Disposition-Notification-To", "Disposition-Notification-Options", "Receipt-Delivery-Option",
// HTTP hop-by-hop
"Connection", "Keep-Alive", "Transfer-Encoding", "TE", "Trailer", "Upgrade",
"Proxy-Authorization", "Proxy-Authenticate",
// Credentials and state of another hop: bridged, an inbound caller's (or an internal service's) token or
// session would reach the trading partner.
"Authorization", "Cookie", "Set-Cookie",
// Belongs to THIS request's target: bridging it from an inbound http consumer turned
// every From(http) -> To(as2) route into an accidental preserve-host proxy.
"Host",
};
///
/// An AS2-name as it goes into AS2-From / AS2-To (RFC 4130 §6.2): as it is when every character is
/// printable ASCII other than space, double quote and backslash (an AS2-atomic-name), else in double quotes with
/// " and \ escaped (an AS2-quoted-name).
///
internal static string FormatName(string name)
{
if (name.Length > 0 && name.All(c => c is > ' ' and <= '~' and not '"' and not '\\'))
return name;
return "\"" + name.Replace("\\", "\\\\", StringComparison.Ordinal).Replace("\"", "\\\"", StringComparison.Ordinal) + "\"";
}
}