pingora_http

Struct ResponseHeader

Source
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

Source

pub fn build( code: impl TryInto<StatusCode>, size_hint: Option<usize>, ) -> Result<Self>

Create a new ResponseHeader with the given status code.

Source

pub fn build_no_case( code: impl TryInto<StatusCode>, size_hint: Option<usize>, ) -> Result<Self>

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.

Source

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.

Source

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).

Source

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

Source

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.

Source

pub fn set_status(&mut self, status: impl TryInto<StatusCode>) -> Result<()>

Set the status code

Source

pub fn set_version(&mut self, version: Version)

Set the HTTP version

Source

pub fn set_reason_phrase(&mut self, reason_phrase: Option<&str>) -> Result<()>

Set the HTTP reason phase. If None, a default reason phase will be used

Source

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

Source

pub fn as_owned_parts(&self) -> RespParts

Clone self into http::response::Parts.

Trait Implementations§

Source§

impl AsRef<Parts> for ResponseHeader

Source§

fn as_ref(&self) -> &RespParts

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for ResponseHeader

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResponseHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for ResponseHeader

Source§

type Target = Parts

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<Parts> for ResponseHeader

Source§

fn from(parts: RespParts) -> ResponseHeader

Converts to this type from the input type.
Source§

impl From<ResponseHeader> for Parts

Source§

fn from(resp: ResponseHeader) -> RespParts

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.