Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not expose crate-private Header struct in public interface #695

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
/// ureq can't know what encoding the header is in, but this function provides
/// an escape hatch for users that need to handle such headers.
#[cfg(any(feature = "http-interop", feature = "charset"))]
pub fn value_raw(&self) -> &[u8] {

Check failure on line 119 in src/header.rs

View workflow job for this annotation

GitHub Actions / Test (native-tls, charset)

method `value_raw` is never used

Check failure on line 119 in src/header.rs

View workflow job for this annotation

GitHub Actions / Test (charset)

method `value_raw` is never used
let mut bytes = &self.line.as_bytes()[self.index + 1..];

if !bytes.is_empty() {
Expand Down Expand Up @@ -152,34 +152,34 @@
}

/// 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
Loading