pub trait HttpClient:
'static
+ Send
+ Sync {
// Required method
fn get(
&self,
url: &str,
follow_redirects: bool,
) -> BoxFuture<'static, Result<HttpResponse>>;
}Expand description
The transport GPUI uses for resources such as image URLs.
Install an implementation with crate::Application::with_http_client; code inside the
app retrieves it with crate::App::http_client. A newly created app uses
NullHttpClient, so URL-backed loads fail until a client is installed. The web
constructors in gpui_platform install a fetch-based client; native applications must
provide one before loading URL-backed assets.
For tests, BlockedHttpClient rejects network access. With the test-support feature,
FakeHttpClient supplies a fixed status without making a request. The
images guide explains loading,
failure placeholders and cache eviction for a retry.
Required Methods§
Sourcefn get(
&self,
url: &str,
follow_redirects: bool,
) -> BoxFuture<'static, Result<HttpResponse>>
fn get( &self, url: &str, follow_redirects: bool, ) -> BoxFuture<'static, Result<HttpResponse>>
Sends a GET request to url and returns its status and complete body.
Follow redirects when follow_redirects is true. Return Err for a transport or
body-read failure. Receiving an HTTP error status, such as 404, is still an Ok
response: callers inspect HttpResponse::status and decide whether to use the body.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl HttpClient for BlockedHttpClient
impl HttpClient for FakeHttpClient
test-support only.