[][src]Struct actix_web::client::ClientRequestBuilder

pub struct ClientRequestBuilder { /* fields omitted */ }

An HTTP Client request builder

This type can be used to construct an instance of ClientRequest through a builder-like pattern.

Methods

impl ClientRequestBuilder
[src]

Set HTTP URI of request.

Set HTTP method of this request.

Set HTTP method of this request.

Set HTTP version of this request.

By default requests's HTTP version depends on network stream

Append a header.

Header gets appended to existing header. To override header use set_header() method.

use http::header;

fn main() {
    let req = ClientRequest::build()
        .header("X-TEST", "value")
        .header(header::CONTENT_TYPE, "application/json")
        .finish()
        .unwrap();
}

Set a header.

Set a header only if it is not yet set.

Set content encoding.

By default ContentEncoding::Identity is used.

Enables automatic chunked transfer encoding

Enable connection upgrade

Set request's content type

Set content length

Set a cookie

use actix_web::{client, http};

fn main() {
    let req = client::ClientRequest::build()
        .cookie(
            http::Cookie::build("name", "value")
                .domain("www.rust-lang.org")
                .path("/")
                .secure(true)
                .http_only(true)
                .finish(),
        )
        .finish()
        .unwrap();
}

Do not add default request headers. By default Accept-Encoding and User-Agent headers are set.

Disable automatic decompress response body

Set write buffer capacity

Default buffer capacity is 32kb

Set request timeout

Request timeout is a total time before response should be received. Default value is 5 seconds.

Send request using custom connector

Send request using existing Connection

This method calls provided closure with builder reference if value is true.

This method calls provided closure with builder reference if value is Some.

Set a body and generate ClientRequest.

ClientRequestBuilder can not be used after this call.

Set a JSON body and generate ClientRequest

ClientRequestBuilder can not be used after this call.

Set a urlencoded body and generate ClientRequest

ClientRequestBuilder can not be used after this call.

Set a streaming body and generate ClientRequest.

ClientRequestBuilder can not be used after this call.

Set an empty body and generate ClientRequest

ClientRequestBuilder can not be used after this call.

This method construct new ClientRequestBuilder

Trait Implementations

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.

Performs the conversion.

impl Debug for ClientRequestBuilder
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl !Send for ClientRequestBuilder

impl !Sync for ClientRequestBuilder

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

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

Performs the conversion.

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

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

The type returned in the event of a conversion error.

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

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

Mutably borrows from an owned value. Read more

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

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[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