Skip to main content

http_request/client/
struct.rs

1use super::*;
2
3/// Shared immutable configuration backing a reusable [`HttpClient`].
4#[derive(Debug)]
5pub(super) struct HttpClientInner {
6    /// Optional base URL prepended to relative request paths.
7    pub(super) base_url: Option<String>,
8    /// Default headers merged into every request produced by the client.
9    pub(super) default_headers: HashMap<String, String>,
10    /// Base request configuration (defaults to `keep_alive = true`).
11    pub(super) config: RequestConfig,
12    /// Optional shared custom TLS root certificate store.
13    pub(super) root_cert: Option<RootCertStore>,
14}
15
16/// Reusable, cheaply cloneable HTTP client with shared base URL, default headers, TLS roots, and keep-alive pooling.
17#[derive(Clone, Debug)]
18pub struct HttpClient {
19    /// Shared immutable client configuration.
20    pub(super) inner: Arc<HttpClientInner>,
21}
22
23/// Fluent builder for constructing a reusable [`HttpClient`].
24#[derive(Clone, Debug)]
25pub struct HttpClientBuilder {
26    /// Optional base URL prepended to relative request paths.
27    pub(super) base_url: Option<String>,
28    /// Default headers merged into every request produced by the client.
29    pub(super) default_headers: HashMap<String, String>,
30    /// Base request configuration (defaults to `keep_alive = true`).
31    pub(super) config: RequestConfig,
32    /// Optional custom TLS root certificate store.
33    pub(super) root_cert: Option<RootCertStore>,
34}