pub struct HttpRedactor { /* private fields */ }Expand description
Applies one immutable HTTP policy to URLs, forms, headers, and bodies.
Implementations§
Source§impl HttpRedactor
impl HttpRedactor
Sourcepub fn new(policy: RedactionPolicy) -> Self
pub fn new(policy: RedactionPolicy) -> Self
Sourcepub fn strict() -> Self
pub fn strict() -> Self
Creates a redactor with the strict policy for untrusted HTTP data.
The strict snapshot masks unknown structured fields and redacts non-root URL paths while retaining the configured resource limits.
Sourcepub const fn policy(&self) -> &RedactionPolicy
pub const fn policy(&self) -> &RedactionPolicy
Returns the immutable HTTP policy snapshot.
§Returns
The policy used by every operation on this redactor.
Sourcepub fn redact_url(&self, url: &Url) -> LogSafeText<'static>
pub fn redact_url(&self, url: &Url) -> LogSafeText<'static>
Redacts a parsed URL into log-safe text.
User information, passwords, fragments, sensitive query values, and non-root paths under a strict policy never reach the result. Complete HTTP URLs used as non-sensitive query values are redacted recursively under fixed nesting and percent-decoding limits; exceeding either limit fails closed.
§Parameters
url- Parsed URL to redact.
§Returns
An owned log-safe URL representation.
Sourcepub fn redact_urls_in_text(&self, text: &str) -> LogSafeText<'static>
pub fn redact_urls_in_text(&self, text: &str) -> LogSafeText<'static>
Redacts every HTTP URL-looking token in diagnostic text.
Surrounding prose and punctuation are preserved. Invalid URL-looking tokens fail closed, and log-control characters are escaped once after all URL replacements are complete.
§Parameters
text- Diagnostic text that may contain absolute HTTP URLs.
§Returns
Owned log-safe text with recognized URLs redacted.
Sourcepub fn redact_url_str(&self, input: &str) -> LogSafeText<'static>
pub fn redact_url_str(&self, input: &str) -> LogSafeText<'static>
Sourcepub fn redact_form(&self, input: &str) -> LogSafeText<'static>
pub fn redact_form(&self, input: &str) -> LogSafeText<'static>
Sourcepub fn redact_headers(&self, headers: &HeaderMap) -> RedactedHeaders
pub fn redact_headers(&self, headers: &HeaderMap) -> RedactedHeaders
Redacts and deterministically renders all HTTP header values.
Native sensitive values are always masked at Secret level before any name-based allow rule can apply. Non-UTF-8 values use a fixed marker.
§Parameters
headers- HTTP header map to redact.
§Returns
An opaque result whose Display and Debug expose only safe text.
Sourcepub fn redact_body(
&self,
capture: BodyCapture<'_>,
content_type: Option<&HeaderValue>,
) -> BodyRedaction
pub fn redact_body( &self, capture: BodyCapture<'_>, content_type: Option<&HeaderValue>, ) -> BodyRedaction
Redacts a checked body capture under hard input and output limits.
Parsers can observe only the prefix selected before dispatch. The final representation is escaped first and then bounded with a complete truncation marker.
§Parameters
capture- Checked complete or source-truncated body capture.content_type- Optional Content-Type used for parser selection.
§Returns
A bounded result exposing only log-safe text and truthful metadata.
Sourcepub fn redact_body_with_content_type_text(
&self,
capture: BodyCapture<'_>,
content_type: Option<&str>,
) -> BodyRedaction
pub fn redact_body_with_content_type_text( &self, capture: BodyCapture<'_>, content_type: Option<&str>, ) -> BodyRedaction
Redacts a checked body capture selected by optional Content-Type text.
This accepts text from callers that do not retain a native HTTP header. Malformed Content-Type syntax is redacted fail-closed.
§Parameters
capture- Checked complete or source-truncated body capture.content_type- Optional Content-Type text used for parser selection.
§Returns
A bounded result exposing only log-safe text and truthful metadata.
Sourcepub fn redact_url_with_session(
&self,
url: &Url,
session: &RedactionSession<'_>,
) -> LogSafeText<'static>
pub fn redact_url_with_session( &self, url: &Url, session: &RedactionSession<'_>, ) -> LogSafeText<'static>
Redacts a URL while consuming the supplied diagnostic session.
Sourcepub fn redact_urls_in_text_with_session(
&self,
text: &str,
session: &RedactionSession<'_>,
) -> LogSafeText<'static>
pub fn redact_urls_in_text_with_session( &self, text: &str, session: &RedactionSession<'_>, ) -> LogSafeText<'static>
Redacts URL-looking tokens while consuming a shared diagnostic session.
Sourcepub fn redact_url_str_with_session(
&self,
input: &str,
session: &RedactionSession<'_>,
) -> LogSafeText<'static>
pub fn redact_url_str_with_session( &self, input: &str, session: &RedactionSession<'_>, ) -> LogSafeText<'static>
Parses and redacts a URL while consuming a shared diagnostic session.
Sourcepub fn redact_form_with_session(
&self,
input: &str,
session: &RedactionSession<'_>,
) -> LogSafeText<'static>
pub fn redact_form_with_session( &self, input: &str, session: &RedactionSession<'_>, ) -> LogSafeText<'static>
Redacts a form while consuming a shared diagnostic session.
Sourcepub fn redact_headers_with_session(
&self,
headers: &HeaderMap,
session: &RedactionSession<'_>,
) -> RedactedHeaders
pub fn redact_headers_with_session( &self, headers: &HeaderMap, session: &RedactionSession<'_>, ) -> RedactedHeaders
Redacts headers while consuming a shared diagnostic session.
Sourcepub fn redact_body_with_session(
&self,
capture: BodyCapture<'_>,
content_type: Option<&HeaderValue>,
session: &RedactionSession<'_>,
) -> BodyRedaction
pub fn redact_body_with_session( &self, capture: BodyCapture<'_>, content_type: Option<&HeaderValue>, session: &RedactionSession<'_>, ) -> BodyRedaction
Redacts a body while consuming a shared diagnostic session.
Trait Implementations§
Source§impl Clone for HttpRedactor
impl Clone for HttpRedactor
Source§fn clone(&self) -> HttpRedactor
fn clone(&self) -> HttpRedactor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more