Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required method
    fn send<'life0, 'async_trait>(
        &'life0 self,
        request: Request<Bytes>,
    ) -> Pin<Box<dyn Future<Output = Result<Response<Body>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Sends one HTTP request and answers with the response, its body still unread.

An implementation must not follow redirects: SPEC §13 has the SDK handle every redirect itself, so the download flow can read a Location and keep credentials on the API origin. Timeouts belong to the implementation, since the SDK cannot interrupt a transport it does not know; the operation deadline of crate::ClientBuilder::operation_deadline bounds the whole call from above.

A failure to get an answer at all — no connection, a timeout, a broken stream — is Error::network; a response with any status is Ok.

Required Methods§

Source

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

Sends the request.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<H: HttpClient + ?Sized> HttpClient for Arc<H>

Source§

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

Implementors§

Source§

impl HttpClient for ReqwestClient

Available on crate feature reqwest only.