diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index 6b8caed9eec5..0a90e0683bc8 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -83,7 +83,9 @@ impl From for Error { impl Error { pub fn is_network_error(&self) -> bool { - matches!(self, Error::HyperError(_) | Error::TimeoutError) + matches!( + self, + Error::HyperError(_) | Error::LegacyHyperError(_) | Error::TimeoutError ) } @@ -96,11 +98,11 @@ impl Error { return err.raw_os_error() == Some(libc::ENETUNREACH); } } + false + } // TODO: Currently, we use the legacy hyper client for all REST requests. If this // changes in the future, we likely need to match on `Error::HyperError` here and // determine how to achieve the equavalent behavior. See DES-1288. - } - // TODO: Match on `Error::HyperError` too? _ => false, } } @@ -129,14 +131,16 @@ impl Error { } } +// TODO: Look into an alternative to using the legacy hyper client `DES-1288` +type RequestClient = + hyper_util::client::legacy::Client>; + /// A service that executes HTTP requests, allowing for on-demand termination of all in-flight /// requests pub(crate) struct RequestService { command_tx: Weak>, - client: RequestClient, command_rx: mpsc::UnboundedReceiver, connector_handle: HttpsConnectorWithSniHandle, - client: hyper_util::client::legacy::Client>, client: RequestClient, connection_mode_provider: T, connection_mode_generation: usize,