remote_server: Remove dependency on libssl and libcrypto (#15446)
Fixes: #15599 Release Notes: - N/A --------- Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
parent
9016de5d63
commit
2c8a6ee7cc
41 changed files with 670 additions and 226 deletions
|
@ -11,13 +11,13 @@ license = "Apache-2.0"
|
|||
workspace = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["http_client"]
|
||||
test-support = [
|
||||
"backtrace",
|
||||
"collections/test-support",
|
||||
"rand",
|
||||
"util/test-support",
|
||||
"http_client/test-support",
|
||||
"http_client?/test-support",
|
||||
]
|
||||
runtime_shaders = []
|
||||
macos-blade = ["blade-graphics", "blade-macros", "blade-util", "bytemuck"]
|
||||
|
@ -40,7 +40,7 @@ derive_more.workspace = true
|
|||
etagere = "0.2"
|
||||
futures.workspace = true
|
||||
gpui_macros.workspace = true
|
||||
http_client.workspace = true
|
||||
http_client = { optional = true, workspace = true }
|
||||
image = "0.25.1"
|
||||
itertools.workspace = true
|
||||
linkme = "0.3"
|
||||
|
|
|
@ -131,6 +131,7 @@ fn main() {
|
|||
PathBuf::from_str("crates/gpui/examples/image/app-icon.png").unwrap(),
|
||||
),
|
||||
remote_resource: "https://picsum.photos/512/512".into(),
|
||||
|
||||
asset_resource: "image/color.svg".into(),
|
||||
})
|
||||
})
|
||||
|
|
|
@ -117,7 +117,7 @@ impl App {
|
|||
Self(AppContext::new(
|
||||
current_platform(false),
|
||||
Arc::new(()),
|
||||
http_client::client(None, None),
|
||||
Arc::new(NullHttpClient),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ impl App {
|
|||
Self(AppContext::new(
|
||||
current_platform(true),
|
||||
Arc::new(()),
|
||||
http_client::client(None, None),
|
||||
Arc::new(NullHttpClient),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,14 @@ impl App {
|
|||
self
|
||||
}
|
||||
|
||||
/// Set the http client for the application
|
||||
pub fn with_http_client(self, http_client: Arc<dyn HttpClient>) -> Self {
|
||||
let mut context_lock = self.0.borrow_mut();
|
||||
context_lock.http_client = http_client;
|
||||
drop(context_lock);
|
||||
self
|
||||
}
|
||||
|
||||
/// Start the application. The provided callback will be called once the
|
||||
/// app is fully launched.
|
||||
pub fn run<F>(self, on_finish_launching: F)
|
||||
|
@ -1512,3 +1520,22 @@ pub struct KeystrokeEvent {
|
|||
/// The action that was resolved for the keystroke, if any
|
||||
pub action: Option<Box<dyn Action>>,
|
||||
}
|
||||
|
||||
struct NullHttpClient;
|
||||
|
||||
impl HttpClient for NullHttpClient {
|
||||
fn send_with_redirect_policy(
|
||||
&self,
|
||||
_req: http_client::Request<http_client::AsyncBody>,
|
||||
_follow_redirects: bool,
|
||||
) -> futures::future::BoxFuture<
|
||||
'static,
|
||||
Result<http_client::Response<http_client::AsyncBody>, anyhow::Error>,
|
||||
> {
|
||||
async move { Err(anyhow!("No HttpClient available")) }.boxed()
|
||||
}
|
||||
|
||||
fn proxy(&self) -> Option<&http_client::Uri> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -345,7 +345,10 @@ impl Asset for ImageAsset {
|
|||
let bytes = match source.clone() {
|
||||
UriOrPath::Path(uri) => fs::read(uri.as_ref())?,
|
||||
UriOrPath::Uri(uri) => {
|
||||
let mut response = client.get(uri.as_ref(), ().into(), true).await?;
|
||||
let mut response = client
|
||||
.get(uri.as_ref(), ().into(), true)
|
||||
.await
|
||||
.map_err(|e| ImageCacheError::Client(Arc::new(e)))?;
|
||||
let mut body = Vec::new();
|
||||
response.body_mut().read_to_end(&mut body).await?;
|
||||
if !response.status().is_success() {
|
||||
|
@ -429,7 +432,7 @@ impl Asset for ImageAsset {
|
|||
pub enum ImageCacheError {
|
||||
/// An error that occurred while fetching an image from a remote source.
|
||||
#[error("http error: {0}")]
|
||||
Client(#[from] http_client::Error),
|
||||
Client(#[from] Arc<anyhow::Error>),
|
||||
/// An error that occurred while reading the image from disk.
|
||||
#[error("IO error: {0}")]
|
||||
Io(Arc<std::io::Error>),
|
||||
|
|
|
@ -128,6 +128,7 @@ pub use executor::*;
|
|||
pub use geometry::*;
|
||||
pub use global::*;
|
||||
pub use gpui_macros::{register_action, test, IntoElement, Render};
|
||||
pub use http_client;
|
||||
pub use input::*;
|
||||
pub use interactive::*;
|
||||
use key_dispatch::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue