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

    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]

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

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

[src]

Set HTTP URI of request.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`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.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`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

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

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

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

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

[src]

Set a header.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`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.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn content_encoding(&mut self, enc: ContentEncoding) -> &mut Self`

[src]

Set content encoding.

By default `ContentEncoding::Identity` is used.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn chunked(&mut self) -> &mut Self`

[src]

Enables automatic chunked transfer encoding

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn upgrade(&mut self) -> &mut Self`

[src]

Enable connection upgrade

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

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

[src]

Set request's content type

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn content_length(&mut self, len: u64) -> &mut Self`

[src]

Set content length

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

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

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`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.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn disable_decompress(&mut self) -> &mut Self`

[src]

Disable automatic decompress response body

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn write_buffer_capacity(&mut self, cap: usize) -> &mut Self`

[src]

Set write buffer capacity

Default buffer capacity is 32kb

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`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.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

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

[src]

Send request using custom connector

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn with_connection(&mut self, conn: Connection) -> &mut Self`

[src]

Send request using existing `Connection`

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`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`.

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`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 Debug for ClientRequestBuilder`

[src]

####

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

[src]

Formats the value using the given formatter. Read more

###

`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.

## Auto Trait Implementations

###

`impl !Send for ClientRequestBuilder`

###

`impl !Sync for ClientRequestBuilder`

# 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`)