Struct actix_web::HttpRequest
[−]
[src]
pub struct HttpRequest<S = ()>(_, _, _);
An HTTP Request
Methods
impl HttpRequest<()>
[src]
ⓘImportant traits for HttpRequest<S>pub fn new(
method: Method,
uri: Uri,
version: Version,
headers: HeaderMap,
payload: Option<Payload>
) -> HttpRequest
[src]
method: Method,
uri: Uri,
version: Version,
headers: HeaderMap,
payload: Option<Payload>
) -> HttpRequest
Construct a new Request.
ⓘImportant traits for HttpRequest<S>pub fn with_state<S>(self, state: Rc<S>, router: Router) -> HttpRequest<S>
[src]
Construct new http request with state.
impl<S> HttpRequest<S>
[src]
ⓘImportant traits for HttpRequest<S>pub fn change_state<NS>(&self, state: Rc<NS>) -> HttpRequest<NS>
[src]
Construct new http request with state.
ⓘImportant traits for HttpRequest<S>pub fn drop_state(&self) -> HttpRequest
[src]
Construct new http request without state.
ⓘImportant traits for &'a mut Wpub fn state(&self) -> &S
[src]
Shared application state
pub fn extensions(&mut self) -> &mut Extensions
[src]
Request extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
[src]
Mutable refernece 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 headers_mut(&mut self) -> &mut HeaderMap
[src]
Returns mutable Request's headers.
This is intended to be used by middleware.
pub fn path(&self) -> &str
[src]
The target path of this Request.
pub fn connection_info(&self) -> &ConnectionInfo
[src]
Get ConnectionInfo for 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]
&self,
name: &str,
elements: U
) -> Result<Url, UrlGenerationError> where
U: IntoIterator<Item = I>,
I: AsRef<str>,
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 router(&self) -> Option<&Router>
[src]
This method returns reference to current Router
object.
pub fn resource(&self) -> &Resource
[src]
This method returns reference to matched Resource
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) -> &Params
[src]
Get a reference to the Params object. Params is a container for url query parameters.
pub fn query_string(&self) -> &str
[src]
The query string in the URL.
E.g., id=10
[src]
Load request cookies.
[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 match_info_mut(&mut self) -> &mut Params
[src]
Get mutable reference to request's Params.
pub fn keep_alive(&self) -> bool
[src]
Checks if a connection should be kept alive.
pub fn set_read_buffer_capacity(&mut self, cap: usize)
[src]
Set read buffer capacity
Default buffer capacity is 32Kb.
Trait Implementations
impl<S> HttpMessage for HttpRequest<S>
[src]
fn headers(&self) -> &HeaderMap
[src]
Read the message headers.
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 range(&self, size: u64) -> Result<Vec<HttpRange>, HttpRangeError>
[src]
Parses Range HTTP header string as per RFC 2616. size
is full size of response (file). Read more
fn body(self) -> MessageBody<Self> where
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
[src]
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
Load http message body. Read more
fn urlencoded<T: DeserializeOwned>(self) -> UrlEncoded<Self, T> where
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
[src]
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
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> where
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
[src]
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
Parse application/json
encoded body. Return JsonBody<T>
future. It resolves to a T
value. Read more
fn multipart(self) -> Multipart<Self> where
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
[src]
Self: Stream<Item = Bytes, Error = PayloadError> + Sized,
Return stream to http payload processes as multipart. Read more
impl Default for HttpRequest<()>
[src]
ⓘImportant traits for HttpRequest<S>fn default() -> HttpRequest
[src]
Construct default request
impl<S> Clone for HttpRequest<S>
[src]
ⓘImportant traits for HttpRequest<S>fn clone(&self) -> HttpRequest<S>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<S: 'static> FromRequest<S> for HttpRequest<S>
[src]
type Config = ()
Configuration for conversion process
type Result = FutureResult<Self, Error>
Future that resolves to a Self
fn from_request(req: &HttpRequest<S>, _: &Self::Config) -> Self::Result
[src]
Convert request to a Self
impl<S> Stream for HttpRequest<S>
[src]
type Item = Bytes
The type of item this stream will yield on success.
type Error = PayloadError
The type of error this stream may generate.
fn poll(&mut self) -> Poll<Option<Bytes>, PayloadError>
[src]
Attempt to pull out the next value of this stream, returning None
if the stream is finished. Read more
ⓘImportant traits for Wait<S>fn wait(self) -> Wait<Self>
[src]
Creates an iterator which blocks the current thread until each item of this stream is resolved. Read more
fn into_future(self) -> StreamFuture<Self>
[src]
Converts this stream into a Future
. Read more
fn map<U, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> U,
[src]
F: FnMut(Self::Item) -> U,
Converts a stream of type T
to a stream of type U
. Read more
fn map_err<U, F>(self, f: F) -> MapErr<Self, F> where
F: FnMut(Self::Error) -> U,
[src]
F: FnMut(Self::Error) -> U,
Converts a stream of error type T
to a stream of error type U
. Read more
fn filter<F>(self, f: F) -> Filter<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
F: FnMut(&Self::Item) -> bool,
Filters the values produced by this stream according to the provided predicate. Read more
fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
[src]
F: FnMut(Self::Item) -> Option<B>,
Filters the values produced by this stream while simultaneously mapping them to a different type. Read more
fn then<F, U>(self, f: F) -> Then<Self, F, U> where
F: FnMut(Result<Self::Item, Self::Error>) -> U,
U: IntoFuture,
[src]
F: FnMut(Result<Self::Item, Self::Error>) -> U,
U: IntoFuture,
Chain on a computation for when a value is ready, passing the resulting item to the provided closure f
. Read more
fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U> where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Error = Self::Error>,
[src]
F: FnMut(Self::Item) -> U,
U: IntoFuture<Error = Self::Error>,
Chain on a computation for when a value is ready, passing the successful results to the provided closure f
. Read more
fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U> where
F: FnMut(Self::Error) -> U,
U: IntoFuture<Item = Self::Item>,
[src]
F: FnMut(Self::Error) -> U,
U: IntoFuture<Item = Self::Item>,
Chain on a computation for when an error happens, passing the erroneous result to the provided closure f
. Read more
fn collect(self) -> Collect<Self>
[src]
Collect all of the values of this stream into a vector, returning a future representing the result of that computation. Read more
fn concat2(self) -> Concat2<Self> where
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
Self::Item: Default,
[src]
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
Self::Item: Default,
Concatenate all results of a stream into a single extendable destination, returning a future representing the end result. Read more
fn concat(self) -> Concat<Self> where
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
[src]
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
: please use Stream::concat2
instead
Concatenate all results of a stream into a single extendable destination, returning a future representing the end result. Read more
fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T> where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
[src]
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Execute an accumulating computation over a stream, collecting all the values into one final result. Read more
fn flatten(self) -> Flatten<Self> where
Self::Item: Stream,
<Self::Item as Stream>::Error: From<Self::Error>,
[src]
Self::Item: Stream,
<Self::Item as Stream>::Error: From<Self::Error>,
Flattens a stream of streams into just one continuous stream. Read more
fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R> where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
[src]
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Skip elements on this stream while the predicate provided resolves to true
. Read more
fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R> where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
[src]
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Take elements from this stream while the predicate provided resolves to true
. Read more
fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U> where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Item = (), Error = Self::Error>,
[src]
F: FnMut(Self::Item) -> U,
U: IntoFuture<Item = (), Error = Self::Error>,
Runs this stream to completion, executing the provided closure for each element on the stream. Read more
fn from_err<E>(self) -> FromErr<Self, E> where
E: From<Self::Error>,
[src]
E: From<Self::Error>,
Map this stream's error to any error implementing From
for this stream's Error
, returning a new stream. Read more
fn take(self, amt: u64) -> Take<Self>
[src]
Creates a new stream of at most amt
items of the underlying stream. Read more
fn skip(self, amt: u64) -> Skip<Self>
[src]
Creates a new stream which skips amt
items of the underlying stream. Read more
fn fuse(self) -> Fuse<Self>
[src]
Fuse a stream such that poll
will never again be called once it has finished. Read more
ⓘImportant traits for &'a mut Wfn by_ref(&mut self) -> &mut Self
[src]
Borrows a stream, rather than consuming it. Read more
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
[src]
Self: UnwindSafe,
Catches unwinding panics while polling the stream. Read more
fn buffered(self, amt: usize) -> Buffered<Self> where
Self::Item: IntoFuture,
<Self::Item as IntoFuture>::Error == Self::Error,
[src]
Self::Item: IntoFuture,
<Self::Item as IntoFuture>::Error == Self::Error,
An adaptor for creating a buffered list of pending futures. Read more
fn buffer_unordered(self, amt: usize) -> BufferUnordered<Self> where
Self::Item: IntoFuture,
<Self::Item as IntoFuture>::Error == Self::Error,
[src]
Self::Item: IntoFuture,
<Self::Item as IntoFuture>::Error == Self::Error,
An adaptor for creating a buffered list of pending futures (unordered). Read more
fn merge<S>(self, other: S) -> Merge<Self, S> where
S: Stream<Error = Self::Error>,
[src]
S: Stream<Error = Self::Error>,
: functionality provided by select
now
An adapter for merging the output of two streams. Read more
fn zip<S>(self, other: S) -> Zip<Self, S> where
S: Stream<Error = Self::Error>,
[src]
S: Stream<Error = Self::Error>,
An adapter for zipping two streams together. Read more
fn chain<S>(self, other: S) -> Chain<Self, S> where
S: Stream<Item = Self::Item, Error = Self::Error>,
[src]
S: Stream<Item = Self::Item, Error = Self::Error>,
Adapter for chaining two stream. Read more
fn peekable(self) -> Peekable<Self>
[src]
Creates a new stream which exposes a peek
method. Read more
fn chunks(self, capacity: usize) -> Chunks<Self>
[src]
An adaptor for chunking up items of the stream inside a vector. Read more
fn select<S>(self, other: S) -> Select<Self, S> where
S: Stream<Item = Self::Item, Error = Self::Error>,
[src]
S: Stream<Item = Self::Item, Error = Self::Error>,
Creates a stream that selects the next element from either this stream or the provided one, whichever is ready first. Read more
fn forward<S>(self, sink: S) -> Forward<Self, S> where
S: Sink<SinkItem = Self::Item>,
Self::Error: From<<S as Sink>::SinkError>,
[src]
S: Sink<SinkItem = Self::Item>,
Self::Error: From<<S as Sink>::SinkError>,
A future that completes after the given stream has been fully processed into the sink, including flushing. Read more
fn split(self) -> (SplitSink<Self>, SplitStream<Self>) where
Self: Sink,
[src]
Self: Sink,
Splits this Stream + Sink
object into separate Stream
and Sink
objects. Read more
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
[src]
F: FnMut(&Self::Item),
Do something with each item of this stream, afterwards passing it on. Read more
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F> where
F: FnMut(&Self::Error),
[src]
F: FnMut(&Self::Error),
Do something with the error of this stream, afterwards passing it on. Read more
impl<S> Read for HttpRequest<S>
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
unsafe fn initializer(&self) -> Initializer
[src]
read_initializer
)Determines if this Read
er can work with buffers of uninitialized memory. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
Read all bytes until EOF in this source, appending them to buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
Read the exact number of bytes required to fill buf
. Read more
ⓘImportant traits for &'a mut Wfn by_ref(&mut self) -> &mut Self
1.0.0[src]
Creates a "by reference" adaptor for this instance of Read
. Read more
ⓘImportant traits for Bytes<R>fn bytes(self) -> Bytes<Self>
1.0.0[src]
Transforms this Read
instance to an [Iterator
] over its bytes. Read more
ⓘImportant traits for Chars<R>fn chars(self) -> Chars<Self>
[src]
🔬 This is a nightly-only experimental API. (io
)
the semantics of a partial read/write of where errors happen is currently unclear and may change
Transforms this Read
instance to an [Iterator
] over [char
]s. Read more
ⓘImportant traits for Chain<T, U>fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
Creates an adaptor which will chain this stream with another. Read more
ⓘImportant traits for Take<T>fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
Creates an adaptor which will read at most limit
bytes from it. Read more
impl<S> AsyncRead for HttpRequest<S>
[src]
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool
[src]
Prepares an uninitialized buffer to be safe to pass to read
. Returns true
if the supplied buffer was zeroed out. Read more
fn poll_read(&mut self, buf: &mut [u8]) -> Result<Async<usize>, Error>
[src]
Attempt to read from the AsyncRead
into buf
. Read more
fn read_buf<B>(&mut self, buf: &mut B) -> Result<Async<usize>, Error> where
B: BufMut,
[src]
B: BufMut,
Pull some bytes from this source into the specified Buf
, returning how many bytes were read. Read more
fn framed<T>(self, codec: T) -> Framed<Self, T> where
Self: AsyncWrite,
T: Decoder + Encoder,
[src]
Self: AsyncWrite,
T: Decoder + Encoder,
Provides a Stream
and Sink
interface for reading and writing to this Io
object, using Decode
and Encode
to read and write the raw data. Read more
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where
Self: AsyncWrite,
[src]
Self: AsyncWrite,
Helper method for splitting this read/write object into two halves. Read more
impl<S> Debug for HttpRequest<S>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, S> From<&'a HttpRequest<S>> for HttpResponseBuilder
[src]
fn from(req: &'a HttpRequest<S>) -> HttpResponseBuilder
[src]
Performs the conversion.
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.
fn from(req: &'a HttpRequest<S>) -> ClientRequestBuilder
[src]
Performs the conversion.
impl<S> RequestIdentity for HttpRequest<S>
[src]
fn identity(&self) -> Option<&str>
[src]
Return the claimed identity of the user associated request or None
if no identity can be found associated with the request. Read more
fn remember(&mut self, identity: String)
[src]
Remember identity.
fn forget(&mut self)
[src]
This method is used to 'forget' the current identity on subsequent requests. Read more