From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- third_party/rust/viaduct/src/settings.rs | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 third_party/rust/viaduct/src/settings.rs (limited to 'third_party/rust/viaduct/src/settings.rs') diff --git a/third_party/rust/viaduct/src/settings.rs b/third_party/rust/viaduct/src/settings.rs new file mode 100644 index 0000000000..6ed204b44e --- /dev/null +++ b/third_party/rust/viaduct/src/settings.rs @@ -0,0 +1,46 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use once_cell::sync::Lazy; +use parking_lot::RwLock; +use std::time::Duration; +use url::Url; + +/// Note: reqwest allows these only to be specified per-Client. concept-fetch +/// allows these to be specified on each call to fetch. I think it's worth +/// keeping a single global reqwest::Client in the reqwest backend, to simplify +/// the way we abstract away from these. +/// +/// In the future, should we need it, we might be able to add a CustomClient type +/// with custom settings. In the reqwest backend this would store a Client, and +/// in the concept-fetch backend it would only store the settings, and populate +/// things on the fly. +#[derive(Debug)] +#[non_exhaustive] +pub struct Settings { + pub read_timeout: Option, + pub connect_timeout: Option, + pub follow_redirects: bool, + pub use_caches: bool, + // For testing purposes, we allow exactly one additional Url which is + // allowed to not be https. + pub addn_allowed_insecure_url: Option, +} + +#[cfg(target_os = "ios")] +const TIMEOUT_DURATION: Duration = Duration::from_secs(7); + +#[cfg(not(target_os = "ios"))] +const TIMEOUT_DURATION: Duration = Duration::from_secs(10); + +// The singleton instance of our settings. +pub static GLOBAL_SETTINGS: Lazy> = Lazy::new(|| { + RwLock::new(Settings { + read_timeout: Some(TIMEOUT_DURATION), + connect_timeout: Some(TIMEOUT_DURATION), + follow_redirects: true, + use_caches: false, + addn_allowed_insecure_url: None, + }) +}); -- cgit v1.2.3