pub trait HttpClient {
// Required methods
fn get(&self, url: &str) -> Result<HttpResponse>;
fn get_bytes(
&self,
url: &str,
headers: &[(&str, &str)],
) -> Result<BytesResponse>;
}Expand description
A GET-only HTTP client. get reads the body as text; get_bytes reads it as
raw bytes with optional request headers (used for GitHub/npm tarball
downloads). A transport failure (DNS, connect, timeout, read) is an Err,
while any HTTP status (including 4xx/5xx) is an Ok.
Required Methods§
fn get(&self, url: &str) -> Result<HttpResponse>
fn get_bytes( &self, url: &str, headers: &[(&str, &str)], ) -> Result<BytesResponse>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".