diff --git a/mullvad-api/src/access.rs b/mullvad-api/src/access.rs index 2c244d151301..276cc1f5613e 100644 --- a/mullvad-api/src/access.rs +++ b/mullvad-api/src/access.rs @@ -38,7 +38,7 @@ struct AccountState { impl AccessTokenStore { pub(crate) fn new(service: RequestServiceHandle) -> Self { - let factory = rest::RequestFactory::new(API.host.clone(), None); + let factory = rest::RequestFactory::new(&API.host, None); let (tx, rx) = mpsc::unbounded(); tokio::spawn(Self::service_requests(rx, service, factory)); Self { tx } diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index aece1d6576c2..ec1bf5c675a5 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -341,7 +341,7 @@ impl Runtime { ) .await; let token_store = access::AccessTokenStore::new(service.clone()); - let factory = rest::RequestFactory::new(API.host.clone(), Some(token_store)); + let factory = rest::RequestFactory::new(&API.host, Some(token_store)); rest::MullvadRestHandle::new( service, diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index 9e2c9fed33d7..c89b4b22c1ef 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -467,13 +467,13 @@ struct NewErrorResponse { #[derive(Clone)] pub struct RequestFactory { - hostname: String, + hostname: &'static str, token_store: Option, default_timeout: Duration, } impl RequestFactory { - pub fn new(hostname: String, token_store: Option) -> Self { + pub fn new(hostname: &'static str, token_store: Option) -> Self { Self { hostname, token_store, @@ -550,7 +550,7 @@ impl RequestFactory { .uri(uri) .header(header::USER_AGENT, HeaderValue::from_static(USER_AGENT)) .header(header::ACCEPT, HeaderValue::from_static("application/json")) - .header(header::HOST, self.hostname.clone()); + .header(header::HOST, self.hostname.to_owned()); let result = request.body(hyper::Body::empty())?; Ok(result)