[][src]Struct actix_web::HttpRequest

pub struct HttpRequest<S = ()> { /* fields omitted */ }

An HTTP Request

Methods

impl<S> HttpRequest<S>[src]

pub fn drop_state(&self) -> HttpRequest[src]

Construct new http request with empty state.

pub fn state(&self) -> &S[src]

Shared application state

pub fn request(&self) -> &Request[src]

Server request

pub fn extensions(&self) -> Ref<Extensions>[src]

Request extensions

pub fn extensions_mut(&self) -> RefMut<Extensions>[src]

Mutable reference to a the request's extensions

pub fn response(&self, status: StatusCode, body: Body) -> HttpResponse[src]

Create http response

pub fn build_response(&self, status: StatusCode) -> HttpResponseBuilder[src]

Create http response builder

pub fn uri(&self) -> &Uri[src]

Read the Request Uri.

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

Read the Request method.

pub fn version(&self) -> Version[src]

Read the Request Version.

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

The target path of this Request.

pub fn connection_info(&self) -> Ref<ConnectionInfo>[src]

Get ConnectionInfo for the correct request.

pub fn url_for<U, I>(
    &self,
    name: &str,
    elements: U
) -> Result<Url, UrlGenerationError> where
    U: IntoIterator<Item = I>,
    I: AsRef<str>, 
[src]

Generate url for named resource

fn index(req: HttpRequest) -> HttpResponse {
    let url = req.url_for("foo", &["1", "2", "3"]); // <- generate url for "foo" resource
    HttpResponse::Ok().into()
}

fn main() {
    let app = App::new()
        .resource("/test/{one}/{two}/{three}", |r| {
             r.name("foo");  // <- set resource name, then it could be used in `url_for`
             r.method(http::Method::GET).f(|_| HttpResponse::Ok());
        })
        .finish();
}

pub fn url_for_static(&self, name: &str) -> Result<Url, UrlGenerationError>[src]

Generate url for named resource

This method is similar to HttpRequest::url_for() but it can be used for urls that do not contain variable parts.

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

This method returns reference to current ResourceInfo object.

pub fn peer_addr(&self) -> Option<SocketAddr>[src]

Peer socket address

Peer address is actual socket address, if proxy is used in front of actix http server, then peer address would be address of this proxy.

To get client connection information connection_info() method should be used.

pub fn query(&self) -> Ref<HashMap<String, String>>[src]

url query parameters.

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

The query string in the URL.

E.g., id=10

pub fn cookies(&self) -> Result<Ref<Vec<Cookie<'static>>>, CookieParseError>[src]

Load request cookies.

pub fn cookie(&self, name: &str) -> Option<Cookie<'static>>[src]

Return request cookie.

pub fn match_info(&self) -> &Params[src]

Get a reference to the Params object.

Params is a container for url parameters. A variable segment is specified in the form {identifier}, where the identifier can be used later in a request handler to access the matched value for that segment.

pub fn set_read_buffer_capacity(&mut self, cap: usize)[src]

Set read buffer capacity

Default buffer capacity is 32Kb.

Methods from Deref<Target = Request>

pub fn uri(&self) -> &Uri[src]

Read the Request Uri.

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

Read the Request method.

pub fn version(&self) -> Version[src]

Read the Request Version.

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

The target path of this Request.

pub fn headers(&self) -> &HeaderMap[src]

Returns Request's headers.

pub fn peer_addr(&self) -> Option<SocketAddr>[src]

Peer socket address

Peer address is actual socket address, if proxy is used in front of actix http server, then peer address would be address of this proxy.

To get client connection information connection_info() method should be used.

pub fn keep_alive(&self) -> bool[src]

Checks if a connection should be kept alive.

pub fn extensions(&self) -> Ref<Extensions>[src]

Request extensions

pub fn extensions_mut(&self) -> RefMut<Extensions>[src]

Mutable reference to a the request's extensions

pub fn upgrade(&self) -> bool[src]

Check if request requires connection upgrade

pub fn connection_info(&self) -> Ref<ConnectionInfo>[src]

Get ConnectionInfo for the correct request.

pub fn stream_extensions(&self) -> Option<&Extensions>[src]

Io stream extensions

pub fn server_settings(&self) -> &ServerSettings[src]

Server settings

Trait Implementations

impl<S> FromRequest<S> for HttpRequest<S>[src]

type Config = ()

Configuration for conversion process

type Result = Self

Future that resolves to a Self

fn extract(req: &HttpRequest<S>) -> Self::Result[src]

Convert request to a Self Read more

impl<S> HttpMessage for HttpRequest<S>[src]

type Stream = Payload

Type of message payload stream

fn content_type(&self) -> &str[src]

Read the request content type. If request does not contain Content-Type header, empty str get returned. Read more

fn encoding(&self) -> Result<EncodingRef, ContentTypeError>[src]

Get content type encoding Read more

fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>[src]

Convert the request content type to a known mime type.

fn chunked(&self) -> Result<bool, ParseError>[src]

Check if request has chunked transfer encoding

fn body(&self) -> MessageBody<Self>[src]

Load http message body. Read more

fn urlencoded<T: DeserializeOwned>(&self) -> UrlEncoded<Self, T>[src]

Parse application/x-www-form-urlencoded encoded request's body. Return UrlEncoded future. Form can be deserialized to any type that implements Deserialize trait from serde. Read more

fn json<T: DeserializeOwned>(&self) -> JsonBody<Self, T>[src]

Parse application/json encoded body. Return JsonBody<T> future. It resolves to a T value. Read more

fn multipart(&self) -> Multipart<Self::Stream>[src]

Return stream to http payload processes as multipart. Read more

fn readlines(&self) -> Readlines<Self>[src]

Return stream of lines.

impl<S> RequestIdentity for HttpRequest<S>[src]

impl<S> RequestSession for HttpRequest<S>[src]

impl<S> Drop for HttpRequest<S>[src]

impl<'a, S> From<&'a HttpRequest<S>> for HttpResponseBuilder[src]

impl<'a, S: 'static> From<&'a HttpRequest<S>> for ClientRequestBuilder[src]

Create ClientRequestBuilder from HttpRequest

It is useful for proxy requests. This implementation copies all request headers and the method.

impl<S> Clone for HttpRequest<S>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<S> Debug for HttpRequest<S>[src]

impl<S> Deref for HttpRequest<S>[src]

type Target = Request

The resulting type after dereferencing.

Auto Trait Implementations

impl<S = ()> !Send for HttpRequest<S>

impl<S = ()> !Sync for HttpRequest<S>

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.

impl<T> Erased for T