ResponseHeaders

Struct ResponseHeaders 

Source
pub struct ResponseHeaders<'b, const N: usize> {
    pub http11: bool,
    pub code: u16,
    pub reason: Option<&'b str>,
    pub headers: Headers<'b, N>,
}
Expand description

Response headers including the response line (HTTP version, status code, reason phrase)

Fields§

§http11: bool

Whether the response is HTTP/1.1

§code: u16

The status code

§reason: Option<&'b str>

The reason phrase, if present

§headers: Headers<'b, N>

The headers

Implementations§

Source§

impl<'b, const N: usize> ResponseHeaders<'b, N>

Source

pub async fn receive<R>( &mut self, buf: &'b mut [u8], input: R, exact: bool, ) -> Result<(&'b mut [u8], usize), Error<R::Error>>
where R: Read,

Parse the headers from the input stream

Source

pub fn resolve<E>( &self, request_connection_type: ConnectionType, ) -> Result<(ConnectionType, BodyType), Error<E>>

Resolve the connection type and body type from the headers

Source

pub async fn send<W>( &self, request_connection_type: ConnectionType, chunked_if_unspecified: bool, output: W, ) -> Result<(ConnectionType, BodyType), Error<W::Error>>
where W: Write,

Send the headers to the output stream, returning the connection type and body type

Source§

impl<const N: usize> ResponseHeaders<'_, N>

Source

pub const fn new() -> Self

Create a new ResponseHeaders instance, defaults to HTTP/1.1 200 OK

Source

pub fn is_ws_upgrade_accepted( &self, nonce: &[u8; 16], buf: &mut [u8; 33], ) -> bool

A utility method to check if the response is a Websocket upgrade response and if the upgrade was accepted

Trait Implementations§

Source§

impl<'b, const N: usize> Debug for ResponseHeaders<'b, N>

Source§

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

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

impl<const N: usize> Default for ResponseHeaders<'_, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> Display for ResponseHeaders<'_, N>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b, const N: usize> Freeze for ResponseHeaders<'b, N>

§

impl<'b, const N: usize> RefUnwindSafe for ResponseHeaders<'b, N>

§

impl<'b, const N: usize> Send for ResponseHeaders<'b, N>

§

impl<'b, const N: usize> Sync for ResponseHeaders<'b, N>

§

impl<'b, const N: usize> Unpin for ResponseHeaders<'b, N>

§

impl<'b, const N: usize> UnwindSafe for ResponseHeaders<'b, N>

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