diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/viaduct/src/settings.rs | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/viaduct/src/settings.rs')
-rw-r--r-- | third_party/rust/viaduct/src/settings.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/third_party/rust/viaduct/src/settings.rs b/third_party/rust/viaduct/src/settings.rs new file mode 100644 index 0000000000..1012ef4753 --- /dev/null +++ b/third_party/rust/viaduct/src/settings.rs @@ -0,0 +1,37 @@ +/* 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 std::time::Duration; + +/// 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, PartialEq)] +#[non_exhaustive] +pub struct Settings { + pub read_timeout: Option<Duration>, + pub connect_timeout: Option<Duration>, + pub follow_redirects: bool, + pub use_caches: bool, +} + +#[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: &Settings = &Settings { + read_timeout: Some(TIMEOUT_DURATION), + connect_timeout: Some(TIMEOUT_DURATION), + follow_redirects: true, + use_caches: false, +}; |