Skip to content

Commit 5d5c4b6

Browse files
authored
Revert http client changes (#18892)
These proved to be too unstable. Will restore these changes once the issues have been fixed. Release Notes: - N/A
1 parent e351148 commit 5d5c4b6

File tree

35 files changed

+381
-1120
lines changed

35 files changed

+381
-1120
lines changed

Cargo.lock

Lines changed: 195 additions & 408 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ members = [
5252
"crates/indexed_docs",
5353
"crates/inline_completion_button",
5454
"crates/install_cli",
55+
"crates/isahc_http_client",
5556
"crates/journal",
5657
"crates/language",
5758
"crates/language_model",
@@ -87,7 +88,6 @@ members = [
8788
"crates/remote",
8889
"crates/remote_server",
8990
"crates/repl",
90-
"crates/reqwest_client",
9191
"crates/rich_text",
9292
"crates/rope",
9393
"crates/rpc",
@@ -122,7 +122,6 @@ members = [
122122
"crates/ui",
123123
"crates/ui_input",
124124
"crates/ui_macros",
125-
"crates/ureq_client",
126125
"crates/util",
127126
"crates/vcs_menu",
128127
"crates/vim",
@@ -230,6 +229,7 @@ image_viewer = { path = "crates/image_viewer" }
230229
indexed_docs = { path = "crates/indexed_docs" }
231230
inline_completion_button = { path = "crates/inline_completion_button" }
232231
install_cli = { path = "crates/install_cli" }
232+
isahc_http_client = { path = "crates/isahc_http_client" }
233233
journal = { path = "crates/journal" }
234234
language = { path = "crates/language" }
235235
language_model = { path = "crates/language_model" }
@@ -266,7 +266,6 @@ release_channel = { path = "crates/release_channel" }
266266
remote = { path = "crates/remote" }
267267
remote_server = { path = "crates/remote_server" }
268268
repl = { path = "crates/repl" }
269-
reqwest_client = { path = "crates/reqwest_client" }
270269
rich_text = { path = "crates/rich_text" }
271270
rope = { path = "crates/rope" }
272271
rpc = { path = "crates/rpc" }
@@ -301,7 +300,6 @@ title_bar = { path = "crates/title_bar" }
301300
ui = { path = "crates/ui" }
302301
ui_input = { path = "crates/ui_input" }
303302
ui_macros = { path = "crates/ui_macros" }
304-
ureq_client = { path = "crates/ureq_client" }
305303
util = { path = "crates/util" }
306304
vcs_menu = { path = "crates/vcs_menu" }
307305
vim = { path = "crates/vim" }
@@ -329,7 +327,7 @@ async-pipe = { git = "https://github.com/zed-industries/async-pipe-rs", rev = "8
329327
async-recursion = "1.0.0"
330328
async-tar = "0.5.0"
331329
async-trait = "0.1"
332-
async-tungstenite = "0.28"
330+
async-tungstenite = "0.23"
333331
async-watch = "0.3.1"
334332
async_zip = { version = "0.0.17", features = ["deflate", "deflate64"] }
335333
base64 = "0.22"
@@ -369,6 +367,10 @@ ignore = "0.4.22"
369367
image = "0.25.1"
370368
indexmap = { version = "1.6.2", features = ["serde"] }
371369
indoc = "2"
370+
# We explicitly disable http2 support in isahc.
371+
isahc = { version = "1.7.2", default-features = false, features = [
372+
"text-decoding",
373+
] }
372374
itertools = "0.13.0"
373375
jsonwebtoken = "9.3"
374376
libc = "0.2"
@@ -393,14 +395,13 @@ pulldown-cmark = { version = "0.12.0", default-features = false }
393395
rand = "0.8.5"
394396
regex = "1.5"
395397
repair_json = "0.1.0"
396-
reqwest = { git = "https://github.com/zed-industries/reqwest.git", rev = "fd110f6998da16bbca97b6dddda9be7827c50e29" }
397398
rsa = "0.9.6"
398399
runtimelib = { version = "0.15", default-features = false, features = [
399400
"async-dispatcher-runtime",
400401
] }
401402
rustc-demangle = "0.1.23"
402403
rust-embed = { version = "8.4", features = ["include-exclude"] }
403-
rustls = "0.21.12"
404+
rustls = "0.20.3"
404405
rustls-native-certs = "0.8.0"
405406
schemars = { version = "0.8", features = ["impl_json_schema"] }
406407
semver = "1.0"

crates/client/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ test-support = ["clock/test-support", "collections/test-support", "gpui/test-sup
1818
[dependencies]
1919
anyhow.workspace = true
2020
async-recursion = "0.3"
21-
async-tls = "0.13"
2221
async-tungstenite = { workspace = true, features = ["async-std", "async-tls"] }
2322
chrono = { workspace = true, features = ["serde"] }
2423
clock.workspace = true
@@ -35,6 +34,8 @@ postage.workspace = true
3534
rand.workspace = true
3635
release_channel.workspace = true
3736
rpc = { workspace = true, features = ["gpui"] }
37+
rustls.workspace = true
38+
rustls-native-certs.workspace = true
3839
schemars.workspace = true
3940
serde.workspace = true
4041
serde_json.workspace = true

crates/client/src/client.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ impl Client {
10231023
&self,
10241024
http: Arc<HttpClientWithUrl>,
10251025
release_channel: Option<ReleaseChannel>,
1026-
) -> impl Future<Output = Result<url::Url>> {
1026+
) -> impl Future<Output = Result<Url>> {
10271027
#[cfg(any(test, feature = "test-support"))]
10281028
let url_override = self.rpc_url.read().clone();
10291029

@@ -1117,7 +1117,7 @@ impl Client {
11171117
// for us from the RPC URL.
11181118
//
11191119
// Among other things, it will generate and set a `Sec-WebSocket-Key` header for us.
1120-
let mut request = IntoClientRequest::into_client_request(rpc_url.as_str())?;
1120+
let mut request = rpc_url.into_client_request()?;
11211121

11221122
// We then modify the request to add our desired headers.
11231123
let request_headers = request.headers_mut();
@@ -1137,13 +1137,30 @@ impl Client {
11371137

11381138
match url_scheme {
11391139
Https => {
1140+
let client_config = {
1141+
let mut root_store = rustls::RootCertStore::empty();
1142+
1143+
let root_certs = rustls_native_certs::load_native_certs();
1144+
for error in root_certs.errors {
1145+
log::warn!("error loading native certs: {:?}", error);
1146+
}
1147+
root_store.add_parsable_certificates(
1148+
&root_certs
1149+
.certs
1150+
.into_iter()
1151+
.map(|cert| cert.as_ref().to_owned())
1152+
.collect::<Vec<_>>(),
1153+
);
1154+
rustls::ClientConfig::builder()
1155+
.with_safe_defaults()
1156+
.with_root_certificates(root_store)
1157+
.with_no_client_auth()
1158+
};
11401159
let (stream, _) =
11411160
async_tungstenite::async_tls::client_async_tls_with_connector(
11421161
request,
11431162
stream,
1144-
Some(async_tls::TlsConnector::from(
1145-
http_client::TLS_CONFIG.clone(),
1146-
)),
1163+
Some(client_config.into()),
11471164
)
11481165
.await?;
11491166
Ok(Connection::new(

crates/collab/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ futures.workspace = true
3737
google_ai.workspace = true
3838
hex.workspace = true
3939
http_client.workspace = true
40+
isahc_http_client.workspace = true
4041
jsonwebtoken.workspace = true
4142
live_kit_server.workspace = true
4243
log.workspace = true
@@ -47,7 +48,6 @@ prometheus = "0.13"
4748
prost.workspace = true
4849
rand.workspace = true
4950
reqwest = { version = "0.11", features = ["json"] }
50-
reqwest_client.workspace = true
5151
rpc.workspace = true
5252
rustc-demangle.workspace = true
5353
scrypt = "0.11"

crates/collab/src/llm.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use chrono::{DateTime, Duration, Utc};
2222
use collections::HashMap;
2323
use db::{usage_measure::UsageMeasure, ActiveUserCount, LlmDatabase};
2424
use futures::{Stream, StreamExt as _};
25-
26-
use reqwest_client::ReqwestClient;
25+
use isahc_http_client::IsahcHttpClient;
2726
use rpc::ListModelsResponse;
2827
use rpc::{
2928
proto::Plan, LanguageModelProvider, PerformCompletionParams, EXPIRED_LLM_TOKEN_HEADER_NAME,
@@ -44,7 +43,7 @@ pub struct LlmState {
4443
pub config: Config,
4544
pub executor: Executor,
4645
pub db: Arc<LlmDatabase>,
47-
pub http_client: ReqwestClient,
46+
pub http_client: IsahcHttpClient,
4847
pub clickhouse_client: Option<clickhouse::Client>,
4948
active_user_count_by_model:
5049
RwLock<HashMap<(LanguageModelProvider, String), (DateTime<Utc>, ActiveUserCount)>>,
@@ -70,8 +69,11 @@ impl LlmState {
7069
let db = Arc::new(db);
7170

7271
let user_agent = format!("Zed Server/{}", env!("CARGO_PKG_VERSION"));
73-
let http_client =
74-
ReqwestClient::user_agent(&user_agent).context("failed to construct http client")?;
72+
let http_client = IsahcHttpClient::builder()
73+
.default_header("User-Agent", user_agent)
74+
.build()
75+
.map(IsahcHttpClient::from)
76+
.context("failed to construct http client")?;
7577

7678
let this = Self {
7779
executor,

crates/collab/src/rpc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ use collections::{HashMap, HashSet};
3636
pub use connection_pool::{ConnectionPool, ZedVersion};
3737
use core::fmt::{self, Debug, Formatter};
3838
use http_client::HttpClient;
39+
use isahc_http_client::IsahcHttpClient;
3940
use open_ai::{OpenAiEmbeddingModel, OPEN_AI_API_URL};
40-
use reqwest_client::ReqwestClient;
4141
use sha2::Digest;
4242
use supermaven_api::{CreateExternalUserRequest, SupermavenAdminApi};
4343

@@ -964,8 +964,8 @@ impl Server {
964964
tracing::info!("connection opened");
965965

966966
let user_agent = format!("Zed Server/{}", env!("CARGO_PKG_VERSION"));
967-
let http_client = match ReqwestClient::user_agent(&user_agent) {
968-
Ok(http_client) => Arc::new(http_client),
967+
let http_client = match IsahcHttpClient::builder().default_header("User-Agent", user_agent).build() {
968+
Ok(http_client) => Arc::new(IsahcHttpClient::from(http_client)),
969969
Err(error) => {
970970
tracing::error!(?error, "failed to create HTTP client");
971971
return;

crates/evals/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fs.workspace = true
2525
git.workspace = true
2626
gpui.workspace = true
2727
http_client.workspace = true
28+
isahc_http_client.workspace = true
2829
language.workspace = true
2930
languages.workspace = true
3031
node_runtime.workspace = true
@@ -35,4 +36,3 @@ serde.workspace = true
3536
serde_json.workspace = true
3637
settings.workspace = true
3738
smol.workspace = true
38-
ureq_client.workspace = true

crates/evals/src/eval.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use std::{
3232
Arc,
3333
},
3434
};
35-
use ureq_client::UreqClient;
3635

3736
const CODESEARCH_NET_DIR: &'static str = "target/datasets/code-search-net";
3837
const EVAL_REPOS_DIR: &'static str = "target/datasets/eval-repos";
@@ -101,11 +100,7 @@ fn main() -> Result<()> {
101100

102101
gpui::App::headless().run(move |cx| {
103102
let executor = cx.background_executor().clone();
104-
let client = Arc::new(UreqClient::new(
105-
None,
106-
"Zed LLM evals".to_string(),
107-
executor.clone(),
108-
));
103+
let client = isahc_http_client::IsahcHttpClient::new(None, None);
109104
cx.set_http_client(client.clone());
110105
match cli.command {
111106
Commands::Fetch {} => {

crates/extension/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ wit-component.workspace = true
5656
workspace.workspace = true
5757

5858
[dev-dependencies]
59+
isahc_http_client.workspace = true
5960
ctor.workspace = true
6061
env_logger.workspace = true
6162
fs = { workspace = true, features = ["test-support"] }
6263
gpui = { workspace = true, features = ["test-support"] }
6364
language = { workspace = true, features = ["test-support"] }
6465
parking_lot.workspace = true
6566
project = { workspace = true, features = ["test-support"] }
66-
reqwest_client.workspace = true
6767
tokio.workspace = true
68-
ureq_client.workspace = true
6968
workspace = { workspace = true, features = ["test-support"] }

0 commit comments

Comments
 (0)