Struct rouille::Request [] [src]

pub struct Request {
    // some fields omitted
}

Represents a request that your handler must answer to.

This can be either a real request (received by the HTTP server) or a mock object created with one of the fake_* constructors.

Methods

impl Request

fn fake_http<U, M>(method: M, url: U, headers: Vec<(String, String)>, data: Vec<u8>) -> Request where U: Into<String>, M: Into<String>

Builds a fake HTTP request to be used during tests.

The remote address of the client will be 127.0.0.1:12345. Use fake_http_from to specify what the client's address should be.

fn fake_http_from<U, M>(from: SocketAddr, method: M, url: U, headers: Vec<(String, String)>, data: Vec<u8>) -> Request where U: Into<String>, M: Into<String>

Builds a fake HTTP request to be used during tests.

fn fake_https<U, M>(method: M, url: U, headers: Vec<(String, String)>, data: Vec<u8>) -> Request where U: Into<String>, M: Into<String>

Builds a fake HTTPS request to be used during tests.

The remote address of the client will be 127.0.0.1:12345. Use fake_https_from to specify what the client's address should be.

fn fake_https_from<U, M>(from: SocketAddr, method: M, url: U, headers: Vec<(String, String)>, data: Vec<u8>) -> Request where U: Into<String>, M: Into<String>

Builds a fake HTTPS request to be used during tests.

fn secure(&self) -> bool

Returns true if the request uses HTTPS instead of HTTP.

fn method(&self) -> &str

Returns the method of the request (GET, POST, etc.).

fn raw_url(&self) -> &str

Returns the URL requested by the client. It is not decoded and thus can contain strings such as %20.

See also url().

fn url(&self) -> String

Returns the URL requested by the client.

Contrary to raw_url, special characters have been decoded. If there is any non-unicode character in the URL, it will be replaced with U+FFFD.

fn get_param(&self, param_name: &str) -> Option<String>

Returns the value of a GET parameter. TODO: clumbsy

fn header(&self, key: &str) -> Option<String>

Returns the value of a header of the request.

Returns None if no such header could be found.

fn data(&self) -> Vec<u8>

UNSTABLE. Returns the body of the request.

Will eventually return an object that implements Read instead of a Vec<u8>.

fn remote_addr(&self) -> &SocketAddr

Returns the address of the client that made this request.