Skip to content

Commit

Permalink
feat(http)!: remove deprecated Headers::contains_ignore_ascii_case
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed May 31, 2024
1 parent 0e50558 commit 0afcd32
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions http/src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,33 +335,6 @@ impl Headers {
.is_some_and(|v| v.eq_ignore_ascii_case(needle))
}

/// Deprecated because is likely not what you want. It is rarely the case that headers should
/// be searched for a matching string instead of carefully parsed according to the appropriate
/// header rule. Naive string matching on headers without regard to header structure is a
/// possible source of spec noncompliance or occasionally security vulnerability, so trillium
/// does not go out of its way to facilitate that.
#[deprecated = "Please open an issue if this behavior is important to you. \
See documentation for deprecation rationale"]
pub fn contains_ignore_ascii_case<'a>(
&self,
name: impl Into<HeaderName<'a>>,
needle: &str,
) -> bool {
self.get_str(name).is_some_and(|h| {
let needle = if needle.chars().all(|c| c.is_ascii_lowercase()) {
SmartCow::Borrowed(needle)
} else {
SmartCow::Owned(needle.chars().map(|c| c.to_ascii_lowercase()).collect())
};

if h.chars().all(|c| c.is_ascii_lowercase()) {
h.contains(&*needle)
} else {
h.to_ascii_lowercase().contains(&*needle)
}
})
}

/// Chainable method to insert a header
pub fn with_inserted_header(
mut self,
Expand Down

0 comments on commit 0afcd32

Please sign in to comment.