Skip to content

Commit

Permalink
fix: do not expose crate-private Header struct in public interface
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto authored Dec 25, 2023
1 parent 4ddcc3a commit 1a8d7a2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,34 +152,34 @@ impl Header {
}

/// For non-utf8 headers this returns [`None`] (use [`get_header_raw()`]).
pub fn get_header<'h>(headers: &'h [Header], name: &str) -> Option<&'h str> {
pub(crate) fn get_header<'h>(headers: &'h [Header], name: &str) -> Option<&'h str> {
headers
.iter()
.find(|h| h.is_name(name))
.and_then(|h| h.value())
}

#[cfg(any(doc, all(test, any(feature = "http-interop", feature = "http-crate"))))]
pub fn get_header_raw<'h>(headers: &'h [Header], name: &str) -> Option<&'h [u8]> {
pub(crate) fn get_header_raw<'h>(headers: &'h [Header], name: &str) -> Option<&'h [u8]> {
headers
.iter()
.find(|h| h.is_name(name))
.map(|h| h.value_raw())
}

pub fn get_all_headers<'h>(headers: &'h [Header], name: &str) -> Vec<&'h str> {
pub(crate) fn get_all_headers<'h>(headers: &'h [Header], name: &str) -> Vec<&'h str> {
headers
.iter()
.filter(|h| h.is_name(name))
.filter_map(|h| h.value())
.collect()
}

pub fn has_header(headers: &[Header], name: &str) -> bool {
pub(crate) fn has_header(headers: &[Header], name: &str) -> bool {
get_header(headers, name).is_some()
}

pub fn add_header(headers: &mut Vec<Header>, header: Header) {
pub(crate) fn add_header(headers: &mut Vec<Header>, header: Header) {
let name = header.name();
if !name.starts_with("x-") && !name.starts_with("X-") {
headers.retain(|h| h.name() != name);
Expand Down

0 comments on commit 1a8d7a2

Please sign in to comment.