summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2021-11-22 13:02:44 +0100
committerDavid Lönnhager <david.l@mullvad.net>2022-03-14 12:08:43 +0100
commitf2e59c64d82d5d49377d01184741d32a2f1d8ba8 (patch)
treed619594b880a0177403b7097dacf3f7b20709112
parentc9f714eea95ee9133e54ea9ab151984c987cb49f (diff)
downloadmullvadvpn-f2e59c64d82d5d49377d01184741d32a2f1d8ba8.tar.xz
mullvadvpn-f2e59c64d82d5d49377d01184741d32a2f1d8ba8.zip
Set user agent for all REST requests
-rw-r--r--mullvad-rpc/src/rest.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/mullvad-rpc/src/rest.rs b/mullvad-rpc/src/rest.rs
index ca12469081..6f36a2a096 100644
--- a/mullvad-rpc/src/rest.rs
+++ b/mullvad-rpc/src/rest.rs
@@ -31,6 +31,8 @@ pub use hyper::StatusCode;
pub type Request = hyper::Request<hyper::Body>;
pub type Response = hyper::Response<hyper::Body>;
+const USER_AGENT: &str = "mullvad-app";
+
const TIMER_CHECK_INTERVAL: Duration = Duration::from_secs(60);
const API_IP_CHECK_DELAY: Duration = Duration::from_secs(15 * 60);
const API_IP_CHECK_INTERVAL: Duration = Duration::from_secs(24 * 60 * 60);
@@ -287,6 +289,7 @@ impl RestRequest {
let mut builder = http::request::Builder::new()
.method(Method::GET)
+ .header(header::USER_AGENT, HeaderValue::from_static(USER_AGENT))
.header(header::ACCEPT, HeaderValue::from_static("application/json"));
if let Some(host) = uri.host() {
builder = builder.header(header::HOST, HeaderValue::from_str(&host)?);
@@ -440,6 +443,7 @@ impl RequestFactory {
let request = http::request::Builder::new()
.method(method)
.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());