forked from hyperium/hyper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(http1): decouple preserving header case from FFI (fixes hyperium…
- Loading branch information
Showing
11 changed files
with
97 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//! HTTP extensions | ||
|
||
use bytes::Bytes; | ||
#[cfg(feature = "http1")] | ||
use http::header::{GetAll, HeaderName, IntoHeaderName}; | ||
use http::HeaderMap; | ||
|
||
/// A map from header names to their original casing as received in an HTTP response. | ||
/// | ||
/// If an HTTP/1 response `res` is parsed on a connection whose option | ||
/// [`http1_preserve_header_case`] was set to true and the response included | ||
/// the following headers: | ||
/// | ||
/// ```ignore | ||
/// x-Bread: Baguette | ||
/// X-BREAD: Pain | ||
/// x-bread: Ficelle | ||
/// ``` | ||
/// | ||
/// Then `res.extensions().get::<HeaderCaseMap>()` will return a map with: | ||
/// | ||
/// ```ignore | ||
/// HeaderCaseMap({ | ||
/// "x-bread": ["x-Bread", "X-BREAD", "x-bread"], | ||
/// }) | ||
/// ``` | ||
/// | ||
/// [`http1_preserve_header_case`]: /client/struct.Client.html#method.http1_preserve_header_case | ||
#[derive(Debug, Default)] | ||
pub(crate) struct HeaderCaseMap(HeaderMap<Bytes>); | ||
|
||
#[cfg(feature = "http1")] | ||
impl HeaderCaseMap { | ||
pub(crate) fn get_all(&self, name: &HeaderName) -> GetAll<'_, Bytes> { | ||
self.0.get_all(name) | ||
} | ||
|
||
#[cfg(any(test, feature = "ffi"))] | ||
pub(crate) fn insert(&mut self, name: HeaderName, orig: Bytes) { | ||
self.0.insert(name, orig); | ||
} | ||
|
||
pub(crate) fn append<N>(&mut self, name: N, orig: Bytes) | ||
where | ||
N: IntoHeaderName, | ||
{ | ||
self.0.append(name, orig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.