pub struct Request { /* private fields */ }
Expand description
The handshake request.
Implementations
sourceimpl Request
impl Request
sourcepub fn header(&self, header: &str) -> Option<&Vec<u8>>
pub fn header(&self, header: &str) -> Option<&Vec<u8>>
Get the value of the first instance of an HTTP header.
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 origin(&self) -> Result<Option<&str>>
pub fn origin(&self) -> Result<Option<&str>>
Get the origin of the request if it comes from a browser.
sourcepub fn hashed_key(&self) -> Result<String>
pub fn hashed_key(&self) -> Result<String>
Get the hashed WebSocket key from this request.
sourcepub fn version(&self) -> Result<&str>
pub fn version(&self) -> Result<&str>
Get the WebSocket protocol version from the request (should be 13).
sourcepub fn protocols(&self) -> Result<Vec<&str>>
pub fn protocols(&self) -> Result<Vec<&str>>
Get the possible protocols for the WebSocket connection.
sourcepub fn add_protocol(&mut self, protocol: &str)
pub fn add_protocol(&mut self, protocol: &str)
Add a possible protocol to this request. This may result in duplicate protocols listed.
sourcepub fn remove_protocol(&mut self, protocol: &str)
pub fn remove_protocol(&mut self, protocol: &str)
Remove a possible protocol from this request.
sourcepub fn extensions(&self) -> Result<Vec<&str>>
pub fn extensions(&self) -> Result<Vec<&str>>
Get the possible extensions for the WebSocket connection.
sourcepub fn add_extension(&mut self, ext: &str)
pub fn add_extension(&mut self, ext: &str)
Add a possible extension to this request.
This may result in duplicate extensions listed. Also, the order of extensions
indicates preference, so if the preference matters, consider using the
Sec-WebSocket-Protocol
header directly.
sourcepub fn remove_extension(&mut self, ext: &str)
pub fn remove_extension(&mut self, ext: &str)
Remove a possible extension from this request. This will remove all configurations of the extension.
sourcepub fn client_addr(&self) -> Result<Option<&str>>
pub fn client_addr(&self) -> Result<Option<&str>>
Get the IP address of the client.
This method will attempt to retrieve the most likely IP address of the requester in the following manner:
If the X-Forwarded-For
header exists, this method will return the left most
address in the list.
If the Forwarded HTTP Header Field exits,
this method will return the left most address indicated by the for
parameter,
if it exists.
Note
This method does not ensure that the address is a valid IP address.
sourcepub fn parse(buf: &[u8]) -> Result<Option<Request>>
pub fn parse(buf: &[u8]) -> Result<Option<Request>>
Attempt to parse an HTTP request from a buffer. If the buffer does not contain a complete
request, this will return Ok(None)
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
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