diff options
Diffstat (limited to 'mullvad-api')
| -rw-r--r-- | mullvad-api/src/lib.rs | 9 | ||||
| -rw-r--r-- | mullvad-api/src/rest.rs | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index 997a0635c7..950ce10345 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -2,6 +2,7 @@ use async_trait::async_trait; #[cfg(target_os = "android")] use futures::channel::mpsc; +use hyper::body::Incoming; #[cfg(target_os = "android")] use mullvad_types::account::{PlayPurchase, PlayPurchasePaymentToken}; use mullvad_types::{ @@ -746,13 +747,17 @@ impl ApiProxy { } pub async fn get_api_addrs(&self) -> Result<Vec<SocketAddr>, rest::Error> { + self.get_api_addrs_response().await?.deserialize().await + } + + pub async fn get_api_addrs_response(&self) -> Result<rest::Response<Incoming>, rest::Error> { let request = self .handle .factory .get(&format!("{APP_URL_PREFIX}/api-addrs"))? .expected_status(&[StatusCode::OK]); - let response = self.handle.service.request(request).await?; - response.deserialize().await + + self.handle.service.request(request).await } /// Check the availablility of `{APP_URL_PREFIX}/api-addrs`. diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index cab3bb7e0f..bab6d8112a 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -512,6 +512,10 @@ where pub async fn deserialize<T: serde::de::DeserializeOwned>(self) -> Result<T> { deserialize_body_inner(self.response).await } + + pub async fn body(self) -> Result<Vec<u8>> { + Ok(BodyExt::collect(self.response).await?.to_bytes().to_vec()) + } } #[derive(serde::Deserialize)] |
