Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions crates/rustapi-extras/src/insight/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! traffic insight collection behavior.

use super::data::InsightData;
use std::borrow::Cow;
use std::collections::HashSet;
use std::sync::Arc;

Expand Down Expand Up @@ -322,7 +323,9 @@ impl InsightConfig {
if self.header_whitelist.contains("*") {
return true;
}
self.header_whitelist.contains(&name.to_lowercase())

self.header_whitelist
.contains(Self::to_lowercase_cow(name).as_ref())
}

/// Check if a response header should be captured.
Expand All @@ -333,13 +336,23 @@ impl InsightConfig {
if self.response_header_whitelist.contains("*") {
return true;
}

self.response_header_whitelist
.contains(&name.to_lowercase())
.contains(Self::to_lowercase_cow(name).as_ref())
}

/// Check if a header is sensitive.
pub(crate) fn is_sensitive_header(&self, name: &str) -> bool {
self.sensitive_headers.contains(&name.to_lowercase())
self.sensitive_headers
.contains(Self::to_lowercase_cow(name).as_ref())
}

fn to_lowercase_cow(s: &str) -> Cow<'_, str> {
if s.chars().any(|c| c.is_uppercase()) {
Cow::Owned(s.to_lowercase())
} else {
Cow::Borrowed(s)
}
}

/// Check if content type is capturable.
Expand Down
Loading