Struct ws::Response
[−]
[src]
pub struct Response { // some fields omitted }
The handshake response.
Methods
impl Response
[src]
fn header_mut(&mut self, header: &str) -> Option<&mut Vec<u8>>
Edit the value of the first instance of an HTTP header.
fn headers(&self) -> &Vec<(String, Vec<u8>)>
Access the request headers.
fn headers_mut(&mut self) -> &mut Vec<(String, Vec<u8>)>
Edit the request headers.
fn status(&self) -> u16
Get the HTTP status code.
fn set_status(&mut self, status: u16)
Set the HTTP status code.
fn reason(&self) -> &str
Get the HTTP status reason.
fn set_reason<R>(&mut self, reason: R) where R: Into<String>
Set the HTTP status reason.
fn key(&self) -> Result<&Vec<u8>>
Get the hashed WebSocket key.
fn protocol(&self) -> Result<Option<&str>>
Get the protocol that the server has decided to use.
fn set_protocol(&mut self, protocol: &str)
Set the protocol that the server has decided to use.
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.
fn add_extension(&mut self, ext: &str)
Add an accepted extension to this response. This may result in duplicate extensions listed.
fn remove_extension(&mut self, ext: &str)
Remove an accepted extension from this response. This will remove all configurations of the extension.
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)
.
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.
fn format<W>(&self, w: &mut W) -> Result<()> where W: Write
Write a response out to a buffer