# actix_web::client::ClientRequest - Rust
API documentation for the Rust `ClientRequest` struct in crate `actix_web`.
Keywords: rust, rustlang, rust-lang, ClientRequest

# [−] [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]

####

`fn default() -> ClientRequest`

[src]

Returns the "default value" for a type. Read more

###

`impl Debug for ClientRequest`

[src]

####

`fn fmt(&self, f: &mut Formatter) -> Result`

[src]

Formats the value using the given formatter. Read more

## Auto Trait Implementations

###

`impl !Send for ClientRequest`

###

`impl !Sync for ClientRequest`

## Blanket Implementations

###

`impl<T> From for T`

[src]

####

`fn from(t: T) -> T`

[src]

Performs the conversion.

###

`impl<T, U> Into for T where U: From<T>,`

[src]

####

`fn into(self) -> U`

[src]

Performs the conversion.

###

`impl<T, U> TryFrom for T where T: From<U>,`

[src]

#### `type Error = !`

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

`impl<T> Borrow for T where T: ?Sized,`

[src]

####

`fn borrow(&self) -> &T`

[src]

Immutably borrows from an owned value. Read more

###

`impl<T> BorrowMut for T where T: ?Sized,`

[src]

####

`fn borrow_mut(&mut self) -> &mut T`

[src]

Mutably borrows from an owned value. Read more

###

`impl<T, U> TryInto for T where U: TryFrom<T>,`

[src]

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

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

`impl<T> Any for T where T: 'static + ?Sized,`

[src]

####

`fn get_type_id(&self) -> TypeId`

[src]

🔬 This is a nightly-only experimental API. (`get_type_id`)

this method will likely be replaced by an associated static

Gets the `TypeId` of `self`. Read more

###

`impl<T> Erased for T`

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)