client: Add support for HTTP/HTTPS proxy (#30812)

Closes #30732

I tested it on my machine, and the HTTP proxy is working properly now.

Release Notes:

- N/A
This commit is contained in:
张小白 2025-05-16 20:35:30 +08:00 committed by GitHub
parent 5112fcebeb
commit d4f47aa653
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 288 additions and 90 deletions

View file

@ -1,7 +1,7 @@
#[cfg(any(test, feature = "test-support"))]
pub mod test;
mod socks;
mod proxy;
pub mod telemetry;
pub mod user;
pub mod zed_urls;
@ -24,13 +24,13 @@ use gpui::{App, AsyncApp, Entity, Global, Task, WeakEntity, actions};
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
use parking_lot::RwLock;
use postage::watch;
use proxy::connect_proxy_stream;
use rand::prelude::*;
use release_channel::{AppVersion, ReleaseChannel};
use rpc::proto::{AnyTypedEnvelope, EnvelopedMessage, PeerId, RequestMessage};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsSources};
use socks::connect_socks_proxy_stream;
use std::pin::Pin;
use std::{
any::TypeId,
@ -1156,7 +1156,7 @@ impl Client {
let handle = cx.update(|cx| gpui_tokio::Tokio::handle(cx)).ok().unwrap();
let _guard = handle.enter();
match proxy {
Some(proxy) => connect_socks_proxy_stream(&proxy, rpc_host).await?,
Some(proxy) => connect_proxy_stream(&proxy, rpc_host).await?,
None => Box::new(TcpStream::connect(rpc_host).await?),
}
};