Skip to main content

zeph_core/
http.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Shared HTTP client construction for consistent timeout and TLS configuration.
5
6use std::time::Duration;
7
8/// Create a shared HTTP client with standard Zeph configuration.
9///
10/// Config: 30s connect timeout, 60s request timeout, rustls TLS,
11/// `zeph/{version}` user-agent, redirect limit 10.
12///
13/// # Panics
14///
15/// Panics if the TLS backend cannot be initialized (should never happen with rustls).
16#[must_use]
17pub fn default_client() -> reqwest::Client {
18    reqwest::Client::builder()
19        .connect_timeout(Duration::from_secs(30))
20        .timeout(Duration::from_secs(60))
21        .user_agent(concat!("zeph/", env!("CARGO_PKG_VERSION")))
22        .redirect(reqwest::redirect::Policy::limited(10))
23        .build()
24        .expect("default HTTP client construction must not fail")
25}
26
27#[cfg(test)]
28mod tests {
29    use super::*;
30
31    #[test]
32    fn client_builds_successfully() {
33        let _client = default_client();
34    }
35}