pub struct Response { /* private fields */ }
Expand description
The handshake response.
Implementations
sourceimpl Response
impl Response
sourcepub fn new<R>(status: u16, reason: R, body: Vec<u8>) -> Response where
R: Into<String>,
pub fn new<R>(status: u16, reason: R, body: Vec<u8>) -> Response where
R: Into<String>,
Construct a generic HTTP response with a body.
sourcepub fn body(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn body(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Get the response body.
sourcepub fn header_mut(&mut self, header: &str) -> Option<&mut Vec<u8>>
pub fn header_mut(&mut self, header: &str) -> Option<&mut Vec<u8>>
Edit the value of the first instance of an HTTP header.
sourcepub fn set_status(&mut self, status: u16)
pub fn set_status(&mut self, status: u16)
Set the HTTP status code.
sourcepub fn set_reason<R>(&mut self, reason: R) where
R: Into<String>,
pub fn set_reason<R>(&mut self, reason: R) where
R: Into<String>,
Set the HTTP status reason.
sourcepub fn protocol(&self) -> Result<Option<&str>>
pub fn protocol(&self) -> Result<Option<&str>>
Get the protocol that the server has decided to use.
sourcepub fn set_protocol(&mut self, protocol: &str)
pub fn set_protocol(&mut self, protocol: &str)
Set the protocol that the server has decided to use.
sourcepub fn extensions(&self) -> Result<Vec<&str>>
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.
sourcepub fn add_extension(&mut self, ext: &str)
pub fn add_extension(&mut self, ext: &str)
Add an accepted extension to this response. This may result in duplicate extensions listed.
sourcepub fn remove_extension(&mut self, ext: &str)
pub fn remove_extension(&mut self, ext: &str)
Remove an accepted extension from this response. This will remove all configurations of the extension.
sourcepub fn parse(buf: &[u8]) -> Result<Option<Response>>
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)
.
sourcepub fn from_request(req: &Request) -> Result<Response>
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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more