[−][src]Struct chttp::client::ClientBuilder
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);
Methods
impl ClientBuilder
[src]
pub fn new() -> Self
[src]
Create a new builder for building a custom client.
pub fn options(self, options: Options) -> Self
[src]
Set the default connection options to use for each request.
If a request has custom options, then they will override any options specified here.
pub fn with_cookies(self) -> Self
[src]
Enable persistent cookie handling using a cookie jar.
pub fn with_middleware(self, middleware: impl Middleware) -> Self
[src]
Add a middleware layer to the client.
pub fn build(&mut self) -> Result<Client, Error>
[src]
Build an HTTP client using the configured options.
If the client fails to initialize, an error will be returned.
Trait Implementations
impl Default for ClientBuilder
[src]
Auto Trait Implementations
impl Send for ClientBuilder
impl Sync for ClientBuilder
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,