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

pub fn uri<U: AsRef<str>>(&mut self, uri: U) -> &mut Self[src]

Set HTTP URI of request.

pub fn method(&mut self, method: Method) -> &mut Self[src]

Set HTTP method of this request.

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

Set HTTP method of this request.

pub fn version(&mut self, version: Version) -> &mut Self[src]

Set HTTP version of this request.

By default requests's HTTP version depends on network stream

pub fn header<K, V>(&mut self, key: K, value: V) -> &mut Self where
    HeaderName: HttpTryFrom<K>,
    V: IntoHeaderValue, 
[src]

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();
}

pub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Self where
    HeaderName: HttpTryFrom<K>,
    V: IntoHeaderValue, 
[src]

Set a header.

pub fn set_header_if_none<K, V>(&mut self, key: K, value: V) -> &mut Self where
    HeaderName: HttpTryFrom<K>,
    V: IntoHeaderValue, 
[src]

Set a header only if it is not yet set.

pub fn content_encoding(&mut self, enc: ContentEncoding) -> &mut Self[src]

Set content encoding.

By default ContentEncoding::Identity is used.

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

Enables automatic chunked transfer encoding

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

Enable connection upgrade

pub fn content_type<V>(&mut self, value: V) -> &mut Self where
    HeaderValue: HttpTryFrom<V>, 
[src]

Set request's content type

pub fn basic_auth<U, P>(
    &mut self,
    username: U,
    password: Option<P>
) -> &mut Self where
    U: Display,
    P: Display
[src]

Set HTTP basic authorization

pub fn bearer_auth<T>(&mut self, token: T) -> &mut Self where
    T: Display
[src]

Set HTTP bearer authentication

pub fn content_length(&mut self, len: u64) -> &mut Self[src]

Set content length

pub fn cookie<'c>(&mut self, cookie: Cookie<'c>) -> &mut Self[src]

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();
}

pub fn no_default_headers(&mut self) -> &mut Self[src]

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

pub fn disable_decompress(&mut self) -> &mut Self[src]

Disable automatic decompress response body

pub fn write_buffer_capacity(&mut self, cap: usize) -> &mut Self[src]

Set write buffer capacity

Default buffer capacity is 32kb

pub fn timeout(&mut self, timeout: Duration) -> &mut Self[src]

Set request timeout

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

pub fn with_connector(&mut self, conn: Addr<ClientConnector>) -> &mut Self[src]

Send request using custom connector

pub fn with_connection(&mut self, conn: Connection) -> &mut Self[src]

Send request using existing Connection

pub fn if_true<F>(&mut self, value: bool, f: F) -> &mut Self where
    F: FnOnce(&mut ClientRequestBuilder), 
[src]

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

pub fn if_some<T, F>(&mut self, value: Option<T>, f: F) -> &mut Self where
    F: FnOnce(T, &mut ClientRequestBuilder), 
[src]

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

pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<ClientRequest, Error>[src]

Set a body and generate ClientRequest.

ClientRequestBuilder can not be used after this call.

pub fn json<T: Serialize>(&mut self, value: T) -> Result<ClientRequest, Error>[src]

Set a JSON body and generate ClientRequest

ClientRequestBuilder can not be used after this call.

pub fn form<T: Serialize>(&mut self, value: T) -> Result<ClientRequest, Error>[src]

Set a urlencoded body and generate ClientRequest

ClientRequestBuilder can not be used after this call.

pub fn streaming<S, E>(&mut self, stream: S) -> Result<ClientRequest, Error> where
    S: Stream<Item = Bytes, Error = E> + 'static,
    E: Into<Error>, 
[src]

Set a streaming body and generate ClientRequest.

ClientRequestBuilder can not be used after this call.

pub fn finish(&mut self) -> Result<ClientRequest, Error>[src]

Set an empty body and generate ClientRequest

ClientRequestBuilder can not be used after this call.

pub fn take(&mut self) -> ClientRequestBuilder[src]

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.

impl Debug for ClientRequestBuilder[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