Struct chttp::client::ClientBuilder

source ·
pub struct ClientBuilder { /* private fields */ }
Expand description

An HTTP client builder, capable of creating custom Client instances with customized behavior.

Example:

use chttp::{http, Client, Options, RedirectPolicy};
use std::time::Duration;

let client = Client::builder()
    .options(Options::default()
        .with_timeout(Some(Duration::from_secs(60)))
        .with_redirect_policy(RedirectPolicy::Limit(10))
        .with_preferred_http_version(Some(http::Version::HTTP_2)))
    .build()?;

let mut response = client.get("https://example.org")?;
let body = response.body_mut().text()?;
println!("{}", body);

Implementations

Set the default connection options to use for each request.

If a request has custom options, then they will override any options specified here.

Build an HTTP client using the configured options.

If the client fails to initialize, an error will be returned.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.