pub trait HttpClient: Send + Sync {
// Required method
fn fetch(
&self,
req: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpClientError>> + Send + '_>>;
}Expand description
HTTP fetch backend trait.
Implementors must satisfy the following contract:
fetchmust internally enforce the total timeout fromreq.timeout(including connect and read body); on timeout, returnHttpClientError::Timeout.- When
req.follow_redirects = true, follow 3xx responses per RFC 7231, up toreq.max_redirectshops; exceeding that returnsHttpClientError::TooManyRedirects. - When reading the body, stop after accumulating
req.max_response_bytesand settruncated = trueon the response. - Any HTTP status (including 4xx/5xx) is considered a success
(
HttpResponse::statusis returned as-is); only transport or decode failures should returnErr.
Required Methods§
fn fetch( &self, req: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpClientError>> + Send + '_>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".