[][src]Struct actix_web::client::ClientRequest

pub struct ClientRequest { /* fields omitted */ }

An HTTP Client Request

use actix_web::{actix, client};

fn main() {
    actix::run(
        || client::ClientRequest::get("http://www.rust-lang.org") // <- Create request builder
            .header("User-Agent", "Actix-web")
            .finish().unwrap()
            .send()                                    // <- Send http request
            .map_err(|_| ())
            .and_then(|response| {                     // <- server http response
                println!("Response: {:?}", response);
                Ok(())
            }),
    );
}

Methods

impl ClientRequest[src]

pub fn get<U: AsRef<str>>(uri: U) -> ClientRequestBuilder[src]

Create request builder for GET request

pub fn head<U: AsRef<str>>(uri: U) -> ClientRequestBuilder[src]

Create request builder for HEAD request

pub fn post<U: AsRef<str>>(uri: U) -> ClientRequestBuilder[src]

Create request builder for POST request

pub fn put<U: AsRef<str>>(uri: U) -> ClientRequestBuilder[src]

Create request builder for PUT request

pub fn delete<U: AsRef<str>>(uri: U) -> ClientRequestBuilder[src]

Create request builder for DELETE request

impl ClientRequest[src]

pub fn build() -> ClientRequestBuilder[src]

Create client request builder

pub fn build_from<T: Into<ClientRequestBuilder>>(
    source: T
) -> ClientRequestBuilder
[src]

Create client request builder

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

Get the request URI

pub fn set_uri(&mut self, uri: Uri)[src]

Set client request URI

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

Get the request method

pub fn set_method(&mut self, method: Method)[src]

Set HTTP Method for the request

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

Get HTTP version for the request

pub fn set_version(&mut self, version: Version)[src]

Set http Version for the request

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

Get the headers from the request

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

Get a mutable reference to the headers

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

is chunked encoding enabled

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

is upgrade request

pub fn content_encoding(&self) -> ContentEncoding[src]

Content encoding

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

Decompress response payload

pub fn write_buffer_capacity(&self) -> usize[src]

Requested write buffer capacity

pub fn body(&self) -> &Body[src]

Get body of this response

pub fn set_body<B: Into<Body>>(&mut self, body: B)[src]

Set a body

pub fn send(self) -> SendRequest[src]

Send request

This method returns a future that resolves to a ClientResponse

Trait Implementations

impl Default for ClientRequest[src]

impl Debug for ClientRequest[src]

Auto Trait Implementations

Blanket Implementations

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

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