pub struct Response { /* private fields */ }
Expand description
The handshake response.
Implementations§
Source§impl Response
impl Response
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)
pub fn set_reason<R>(&mut self, reason: R)
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.