Struct Response

Source
pub struct Response { /* private fields */ }
Expand description

The handshake response.

Implementations§

Source§

impl Response

Source

pub fn header_mut(&mut self, header: &str) -> Option<&mut Vec<u8>>

Edit the value of the first instance of an HTTP header.

Source

pub fn headers(&self) -> &Vec<(String, Vec<u8>)>

Access the request headers.

Source

pub fn headers_mut(&mut self) -> &mut Vec<(String, Vec<u8>)>

Edit the request headers.

Source

pub fn status(&self) -> u16

Get the HTTP status code.

Source

pub fn set_status(&mut self, status: u16)

Set the HTTP status code.

Source

pub fn reason(&self) -> &str

Get the HTTP status reason.

Source

pub fn set_reason<R>(&mut self, reason: R)
where R: Into<String>,

Set the HTTP status reason.

Source

pub fn key(&self) -> Result<&Vec<u8>>

Get the hashed WebSocket key.

Source

pub fn protocol(&self) -> Result<Option<&str>>

Get the protocol that the server has decided to use.

Source

pub fn set_protocol(&mut self, protocol: &str)

Set the protocol that the server has decided to use.

Source

pub fn extensions(&self) -> Result<Vec<&str>>

Get the extensions that the server has decided to use. If these are unacceptable, it is appropriate to send an Extension close code.

Source

pub fn add_extension(&mut self, ext: &str)

Add an accepted extension to this response. This may result in duplicate extensions listed.

Source

pub fn remove_extension(&mut self, ext: &str)

Remove an accepted extension from this response. This will remove all configurations of the extension.

Source

pub fn parse(buf: &[u8]) -> Result<Option<Response>>

Attempt to parse an HTTP response from a buffer. If the buffer does not contain a complete response, thiw will return Ok(None).

Source

pub fn from_request(req: &Request) -> Result<Response>

Construct a new WebSocket handshake HTTP response from a request. This will create a response that ignores protocols and extensions. Edit this response to accept a protocol and extensions as necessary.

Source

pub fn format<W>(&self, w: &mut W) -> Result<()>
where W: Write,

Write a response out to a buffer

Trait Implementations§

Source§

impl Debug for Response

Source§

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

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

impl Display for Response

Source§

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

Formats the value using the given formatter. Read more

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.