Struct qws::Request[][src]

pub struct Request { /* fields omitted */ }

The handshake request.

Implementations

impl Request[src]

pub fn header(&self, header: &str) -> Option<&Vec<u8>>[src]

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

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

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

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

Access the request headers.

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

Edit the request headers.

pub fn origin(&self) -> Result<Option<&str>>[src]

Get the origin of the request if it comes from a browser.

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

Get the unhashed WebSocket key sent in the request.

pub fn hashed_key(&self) -> Result<String>[src]

Get the hashed WebSocket key from this request.

pub fn version(&self) -> Result<&str>[src]

Get the WebSocket protocol version from the request (should be 13).

pub fn method(&self) -> &str[src]

Get the request method.

pub fn resource(&self) -> &str[src]

Get the path of the request.

pub fn protocols(&self) -> Result<Vec<&str>>[src]

Get the possible protocols for the WebSocket connection.

pub fn add_protocol(&mut self, protocol: &str)[src]

Add a possible protocol to this request. This may result in duplicate protocols listed.

pub fn remove_protocol(&mut self, protocol: &str)[src]

Remove a possible protocol from this request.

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

Get the possible extensions for the WebSocket connection.

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

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.

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

Remove a possible extension from this request. This will remove all configurations of the extension.

pub fn client_addr(&self) -> Result<Option<&str>>[src]

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.

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

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

pub fn from_url(url: &Url) -> Result<Request>[src]

Construct a new WebSocket handshake HTTP request from a url.

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

Write a request out to a buffer

Trait Implementations

impl Debug for Request[src]

impl Display for Request[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.