Struct websocket::server::request::Request [] [src]

pub struct Request<R: Read, W: Write> {
    pub method: Method,
    pub url: RequestUri,
    pub version: HttpVersion,
    pub headers: Headers,
    // some fields omitted
}

Represents a server-side (incoming) request.

Fields

method

The HTTP method used to create the request. All values except Method::Get are rejected by validate().

url

The target URI for this request.

version

The HTTP version of this request.

headers

The headers of this request.

Methods

impl<R: Read, W: Write> Request<R, W>

fn key(&self) -> Option<&WebSocketKey>

Short-cut to obtain the WebSocketKey value.

fn version(&self) -> Option<&WebSocketVersion>

Short-cut to obtain the WebSocketVersion value.

fn protocol(&self) -> Option<&WebSocketProtocol>

Short-cut to obtain the WebSocketProtocol value.

fn extensions(&self) -> Option<&WebSocketExtensions>

Short-cut to obtain the WebSocketExtensions value.

fn origin(&self) -> Option<&Origin>

Short-cut to obtain the Origin value.

fn get_reader(&self) -> &R

Returns a reference to the inner Reader.

fn get_writer(&self) -> &W

Returns a reference to the inner Writer.

fn get_mut_reader(&mut self) -> &mut R

Returns a mutable reference to the inner Reader.

fn get_mut_writer(&mut self) -> &mut W

Returns a mutable reference to the inner Writer.

fn into_inner(self) -> (R, W)

Return the inner Reader and Writer

fn read(reader: R, writer: W) -> WebSocketResult<Request<R, W>>

Reads an inbound request.

This method is used within servers, and returns an inbound WebSocketRequest. An error will be returned if the request cannot be read, or is not a valid HTTP request.

This method does not have any restrictions on the Request. All validation happens in the validate method.

fn validate(&self) -> WebSocketResult<()>

Check if this constitutes a valid WebSocket upgrade request.

Note that accept() calls this function internally, however this may be useful for handling requests in a custom way.

fn accept(self) -> Response<R, W>

Accept this request, ready to send a response.

This function calls validate() on the request, and if the request is found to be invalid, generates a response with a Bad Request status code.

fn fail(self) -> Response<R, W>

Fail this request by generating a Bad Request response

Trait Implementations

impl<R, W> Send for Request<R, W> where R: Read + Send, W: Write + Send