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.
The Go SDK takes an *http.Client and leaves the transport to it. Rust takes a trait
instead: the shells this SDK exists for bring the platform’s own HTTP stack, and a
second one in the binary is the wrong price for a client library. The SDK does the rest
above this seam — credentials, retries, redirects, the response cache, the body caps —
so an implementation is only a transport.
An implementation must not follow redirects. The SDK follows them itself, so it can
keep credentials on the HEY origin and read the Location a form request was made for.
One that follows them anyway loses that Location, and the SDK cannot tell that it did.
Timeouts belong to the implementation, since the SDK has no way to interrupt a transport
it does not know. 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§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl HttpClient for ReqwestClient
reqwest only.