pub struct RequestHeader { /* private fields */ }
Expand description
The HTTP request header type.
This type is similar to http::request::Parts but preserves header name case. It also preserves request path even if it is not UTF-8.
RequestHeader implements Deref for http::request::Parts so it can be used as it in most places.
Implementations§
Source§impl RequestHeader
impl RequestHeader
Sourcepub fn build(
method: impl TryInto<Method>,
path: &[u8],
size_hint: Option<usize>,
) -> Result<Self>
pub fn build( method: impl TryInto<Method>, path: &[u8], size_hint: Option<usize>, ) -> Result<Self>
Create a new RequestHeader with the given method and path.
The path
can be non UTF-8.
Sourcepub fn build_no_case(
method: impl TryInto<Method>,
path: &[u8],
size_hint: Option<usize>,
) -> Result<Self>
pub fn build_no_case( method: impl TryInto<Method>, path: &[u8], size_hint: Option<usize>, ) -> Result<Self>
Create a new RequestHeader with the given method and path without preserving header case.
A RequestHeader created from this type is more space efficient than those from Self::build().
Use this method if reading from or writing to HTTP/2 sessions where header case doesn’t matter anyway.
Sourcepub fn append_header(
&mut self,
name: impl IntoCaseHeaderName,
value: impl TryInto<HeaderValue>,
) -> Result<bool>
pub fn append_header( &mut self, name: impl IntoCaseHeaderName, value: impl TryInto<HeaderValue>, ) -> Result<bool>
Append the header name and value to self
.
If there are already some headers under the same name, a new value will be added without any others being removed.
Sourcepub fn insert_header(
&mut self,
name: impl IntoCaseHeaderName,
value: impl TryInto<HeaderValue>,
) -> Result<()>
pub fn insert_header( &mut self, name: impl IntoCaseHeaderName, value: impl TryInto<HeaderValue>, ) -> Result<()>
Insert the header name and value to self
.
Different from Self::append_header(), this method will replace all other existing headers under the same name (case-insensitive).
Sourcepub fn remove_header<'a, N: ?Sized>(
&mut self,
name: &'a N,
) -> Option<HeaderValue>where
&'a N: 'a + AsHeaderName,
pub fn remove_header<'a, N: ?Sized>(
&mut self,
name: &'a N,
) -> Option<HeaderValue>where
&'a N: 'a + AsHeaderName,
Remove all headers under the name
Sourcepub fn header_to_h1_wire(&self, buf: &mut impl BufMut)
pub fn header_to_h1_wire(&self, buf: &mut impl BufMut)
Write the header to the buf
in HTTP/1.1 wire format.
The header case will be preserved.
Sourcepub fn set_method(&mut self, method: Method)
pub fn set_method(&mut self, method: Method)
Set the request method
Sourcepub fn set_send_end_stream(&mut self, send_end_stream: bool)
pub fn set_send_end_stream(&mut self, send_end_stream: bool)
Set whether we send an END_STREAM on H2 request HEADERS if body is empty.
Sourcepub fn send_end_stream(&self) -> Option<bool>
pub fn send_end_stream(&self) -> Option<bool>
Returns if we support sending an END_STREAM on H2 request HEADERS if body is empty, returns None if not H2.
Sourcepub fn raw_path(&self) -> &[u8] ⓘ
pub fn raw_path(&self) -> &[u8] ⓘ
Return the request path in its raw format
Non-UTF8 is supported.
Sourcepub fn uri_file_extension(&self) -> Option<&str>
pub fn uri_file_extension(&self) -> Option<&str>
Return the file extension of the path
Sourcepub fn set_version(&mut self, version: Version)
pub fn set_version(&mut self, version: Version)
Set http version
Sourcepub fn as_owned_parts(&self) -> ReqParts
pub fn as_owned_parts(&self) -> ReqParts
Clone self
into http::request::Parts.
Trait Implementations§
Source§impl AsRef<Parts> for RequestHeader
impl AsRef<Parts> for RequestHeader
Source§impl Clone for RequestHeader
impl Clone for RequestHeader
Source§impl Debug for RequestHeader
impl Debug for RequestHeader
Source§impl Deref for RequestHeader
impl Deref for RequestHeader
Source§impl From<Parts> for RequestHeader
impl From<Parts> for RequestHeader
Source§fn from(parts: ReqParts) -> RequestHeader
fn from(parts: ReqParts) -> RequestHeader
Source§impl From<RequestHeader> for Parts
impl From<RequestHeader> for Parts
Source§fn from(resp: RequestHeader) -> ReqParts
fn from(resp: RequestHeader) -> ReqParts
Auto Trait Implementations§
impl !Freeze for RequestHeader
impl !RefUnwindSafe for RequestHeader
impl Send for RequestHeader
impl Sync for RequestHeader
impl Unpin for RequestHeader
impl !UnwindSafe for RequestHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)