Trait http_client::HttpClient[][src]

pub trait HttpClient: Debug + Unpin + Send + Sync + 'static {
    #[must_use]
    fn send<'life0, 'async_trait>(
        &'life0 self,
        req: Request
    ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn set_config(&mut self, _config: Config) -> Result<()> { ... }
fn config(&self) -> &Config { ... } }
Expand description

An abstract HTTP client.

note that this is only exposed for use in middleware. Building new backing clients is not recommended yet. Once it is we’ll likely publish a new http_client crate, and re-export this trait from there together with all existing HTTP client implementations.

Spawning new request from middleware

When threading the trait through a layer of middleware, the middleware must be able to perform new requests. In order to enable this efficiently an HttpClient instance may want to be passed though middleware for one of its own requests, and in order to do so should be wrapped in an Rc/Arc to enable reference cloning.

Required methods

#[must_use]
fn send<'life0, 'async_trait>(
    &'life0 self,
    req: Request
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Perform a request.

Provided methods

fn set_config(&mut self, _config: Config) -> Result<()>[src]

Override the existing configuration with new configuration.

Config options may not impact existing connections.

fn config(&self) -> &Config[src]

Get the current configuration.

Implementations on Foreign Types

impl HttpClient for Box<dyn HttpClient>[src]

fn send<'life0, 'async_trait>(
    &'life0 self,
    req: Request
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn set_config(&mut self, config: Config) -> Result<()>[src]

fn config(&self) -> &Config[src]

Implementors

impl HttpClient for H1Client[src]

This is supported on crate features h1_client and default only.

fn set_config(&mut self, config: Config) -> Result<()>[src]

Override the existing configuration with new configuration.

Config options may not impact existing connections.

fn config(&self) -> &Config[src]

Get the current configuration.

fn send<'life0, 'async_trait>(
    &'life0 self,
    req: Request
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

impl HttpClient for HyperClient[src]

This is supported on crate feature hyper_client only.

fn set_config(&mut self, config: Config) -> Result<()>[src]

Override the existing configuration with new configuration.

Config options may not impact existing connections.

fn config(&self) -> &Config[src]

Get the current configuration.

fn send<'life0, 'async_trait>(
    &'life0 self,
    req: Request
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

impl HttpClient for IsahcClient[src]

This is supported on crate feature curl_client only.

fn set_config(&mut self, config: Config) -> Result<()>[src]

Override the existing configuration with new configuration.

Config options may not impact existing connections.

fn config(&self) -> &Config[src]

Get the current configuration.

fn send<'life0, 'async_trait>(
    &'life0 self,
    req: Request
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]