π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[rust][core] fix wasm and HTTP client checks
Neeraj Gupta755611f50507
diff --git a/mobile/packages/rust/rust/src/api/http.rs b/mobile/packages/rust/rust/src/api/http.rsindex de961e4401..e44131cb20 100644--- a/mobile/packages/rust/rust/src/api/http.rs+++ b/mobile/packages/rust/rust/src/api/http.rs@@ -52,7 +52,7 @@ impl HttpClient {#[frb(sync)]pub fn new(base_url: String) -> HttpClient {Self {- inner: CoreHttpClient::new(&base_url),+ inner: CoreHttpClient::new(&base_url).expect("failed to build HTTP client"),}}diff --git a/rust/core/src/http.rs b/rust/core/src/http.rsindex 3898180e7e..84bcb0b664 100644--- a/rust/core/src/http.rs+++ b/rust/core/src/http.rs@@ -1,6 +1,7 @@//! HTTP client for communicating with the Ente API.use std::sync::RwLock;+#[cfg(not(target_arch = "wasm32"))]use std::time::Duration;use reqwest::header::{HeaderMap, HeaderName, HeaderValue, LOCATION};@@ -114,7 +115,11 @@ impl HttpClient {}});+ #[cfg(not(target_arch = "wasm32"))]let mut builder = reqwest::Client::builder();+ #[cfg(target_arch = "wasm32")]+ let builder = reqwest::Client::builder();+ #[cfg(not(target_arch = "wasm32"))]if let Some(timeout) = config.timeout_secs {builder = builder.timeout(Duration::from_secs(timeout));}@@ -299,11 +304,11 @@ impl HttpClient {.headers(headers).send().await?;- if response.status().is_redirection() {- if let Some(location) = response.headers().get(LOCATION) {- current_url = self.resolve_redirect(¤t_url, location)?;- continue;- }+ if response.status().is_redirection()+ && let Some(location) = response.headers().get(LOCATION)+ {+ current_url = self.resolve_redirect(¤t_url, location)?;+ continue;}return parse_bytes_response(response).await;}@@ -336,11 +341,11 @@ impl HttpClient {.body(body.to_vec()).send().await?;- if response.status().is_redirection() {- if let Some(location) = response.headers().get(LOCATION) {- current_url = self.resolve_redirect(¤t_url, location)?;- continue;- }+ if response.status().is_redirection()+ && let Some(location) = response.headers().get(LOCATION)+ {+ current_url = self.resolve_redirect(¤t_url, location)?;+ continue;}return parse_empty_response(response).await;}diff --git a/web/packages/wasm/src/http.rs b/web/packages/wasm/src/http.rsindex 5afd950fd0..02fe0f3c4e 100644--- a/web/packages/wasm/src/http.rs+++ b/web/packages/wasm/src/http.rs@@ -71,7 +71,7 @@ impl HttpClient {#[wasm_bindgen(constructor)]pub fn new(base_url: &str) -> Self {Self {- inner: CoreHttpClient::new(base_url),+ inner: CoreHttpClient::new(base_url).expect("failed to build HTTP client"),}}