pub struct ResponseHeader { /* private fields */ }Expand description
The HTTP response header type.
This type is similar to http::response::Parts but preserves header name case. ResponseHeader implements Deref for http::response::Parts so it can be used as it in most places.
Implementations§
Source§impl ResponseHeader
impl ResponseHeader
Sourcepub fn build(
code: impl TryInto<StatusCode>,
size_hint: Option<usize>,
) -> Result<ResponseHeader, Box<Error>>
pub fn build( code: impl TryInto<StatusCode>, size_hint: Option<usize>, ) -> Result<ResponseHeader, Box<Error>>
Create a new ResponseHeader with the given status code.
Sourcepub fn build_no_case(
code: impl TryInto<StatusCode>,
size_hint: Option<usize>,
) -> Result<ResponseHeader, Box<Error>>
pub fn build_no_case( code: impl TryInto<StatusCode>, size_hint: Option<usize>, ) -> Result<ResponseHeader, Box<Error>>
Create a new ResponseHeader with the given status code without preserving header case.
A ResponseHeader 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, Box<Error>>
pub fn append_header( &mut self, name: impl IntoCaseHeaderName, value: impl TryInto<HeaderValue>, ) -> Result<bool, Box<Error>>
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<(), Box<Error>>
pub fn insert_header( &mut self, name: impl IntoCaseHeaderName, value: impl TryInto<HeaderValue>, ) -> Result<(), Box<Error>>
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>(&mut self, name: &'a N) -> Option<HeaderValue>
pub fn remove_header<'a, N>(&mut self, name: &'a N) -> Option<HeaderValue>
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_status(
&mut self,
status: impl TryInto<StatusCode>,
) -> Result<(), Box<Error>>
pub fn set_status( &mut self, status: impl TryInto<StatusCode>, ) -> Result<(), Box<Error>>
Set the status code
Sourcepub fn set_version(&mut self, version: Version)
pub fn set_version(&mut self, version: Version)
Set the HTTP version
Sourcepub fn set_reason_phrase(
&mut self,
reason_phrase: Option<&str>,
) -> Result<(), Box<Error>>
pub fn set_reason_phrase( &mut self, reason_phrase: Option<&str>, ) -> Result<(), Box<Error>>
Set the HTTP reason phase. If None, a default reason phase will be used
Sourcepub fn get_reason_phrase(&self) -> Option<&str>
pub fn get_reason_phrase(&self) -> Option<&str>
Get the HTTP reason phase. If Self::set_reason_phrase() is never called
or set to None, a default reason phase will be used
Sourcepub fn as_owned_parts(&self) -> Parts
pub fn as_owned_parts(&self) -> Parts
Clone self into http::response::Parts.
Trait Implementations§
Source§impl AsRef<Parts> for ResponseHeader
impl AsRef<Parts> for ResponseHeader
Source§impl Clone for ResponseHeader
impl Clone for ResponseHeader
Source§fn clone(&self) -> ResponseHeader
fn clone(&self) -> ResponseHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResponseHeader
impl Debug for ResponseHeader
Source§impl Deref for ResponseHeader
impl Deref for ResponseHeader
Source§impl From<Parts> for ResponseHeader
impl From<Parts> for ResponseHeader
Source§fn from(parts: Parts) -> ResponseHeader
fn from(parts: Parts) -> ResponseHeader
Source§impl From<ResponseHeader> for Parts
impl From<ResponseHeader> for Parts
Source§fn from(resp: ResponseHeader) -> Parts
fn from(resp: ResponseHeader) -> Parts
Auto Trait Implementations§
impl Freeze for ResponseHeader
impl !RefUnwindSafe for ResponseHeader
impl Send for ResponseHeader
impl Sync for ResponseHeader
impl Unpin for ResponseHeader
impl !UnwindSafe for ResponseHeader
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.