Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Update `post_json` to take in a bool for allowing for redirects

Joseph Lyons69a4fffae243
diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs
index 7151dcd7bb0..5dfb6595d15 100644
--- a/crates/client/src/telemetry.rs
+++ b/crates/client/src/telemetry.rs
@@ -270,7 +270,7 @@ impl Telemetry {
}])?;
this.http_client
- .post_json(MIXPANEL_ENGAGE_URL, json_bytes.into())
+ .post_json(MIXPANEL_ENGAGE_URL, json_bytes.into(), false)
.await?;
anyhow::Ok(())
}
@@ -404,7 +404,7 @@ impl Telemetry {
json_bytes.clear();
serde_json::to_writer(&mut json_bytes, &events)?;
this.http_client
- .post_json(MIXPANEL_EVENTS_URL, json_bytes.into())
+ .post_json(MIXPANEL_EVENTS_URL, json_bytes.into(), false)
.await?;
anyhow::Ok(())
}
@@ -454,7 +454,7 @@ impl Telemetry {
}
this.http_client
- .post_json(CLICKHOUSE_EVENTS_URL.as_str(), json_bytes.into())
+ .post_json(CLICKHOUSE_EVENTS_URL.as_str(), json_bytes.into(), false)
.await?;
anyhow::Ok(())
}
diff --git a/crates/util/src/http.rs b/crates/util/src/http.rs
index e29768a53e8..e7f39552b0f 100644
--- a/crates/util/src/http.rs
+++ b/crates/util/src/http.rs
@@ -40,8 +40,14 @@ pub trait HttpClient: Send + Sync {
&'a self,
uri: &str,
body: AsyncBody,
+ follow_redirects: bool,
) -> BoxFuture<'a, Result<Response<AsyncBody>, Error>> {
let request = isahc::Request::builder()
+ .redirect_policy(if follow_redirects {
+ RedirectPolicy::Follow
+ } else {
+ RedirectPolicy::None
+ })
.method(Method::POST)
.uri(uri)
.header("Content-Type", "application/json")