nyquest_interface/client/
options.rs

1//! Configuration options for HTTP clients.
2
3use std::time::Duration;
4
5/// Defines how the HTTP client should handle response caching.
6#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
7pub enum CachingBehavior {
8    /// Caching is completely disabled.
9    Disabled,
10    /// Best effort caching behavior based on the backend capabilities.
11    #[default]
12    BestEffort,
13}
14
15/// Configuration options for creating a nyquest HTTP client.
16#[derive(Debug, Clone)]
17pub struct ClientOptions {
18    /// Optional base URL prepended to all request URLs.
19    pub base_url: Option<String>,
20    /// Optional User-Agent header value to use for all requests.
21    pub user_agent: Option<String>,
22    /// Headers to include in all requests by default.
23    pub default_headers: Vec<(String, String)>,
24    /// Controls the caching behavior for HTTP responses.
25    pub caching_behavior: CachingBehavior,
26    /// Whether to use the system's default proxy settings.
27    pub use_default_proxy: bool,
28    /// Whether to enable cookie handling.
29    pub use_cookies: bool,
30    /// Whether to automatically follow redirect responses.
31    pub follow_redirects: bool,
32    /// Optional maximum buffer size for response bodies.
33    pub max_response_buffer_size: Option<u64>,
34    /// Optional timeout duration for requests.
35    pub request_timeout: Option<Duration>,
36    /// Whether to ignore SSL certificate errors.
37    pub ignore_certificate_errors: bool,
38    // TODO: auth
39    // TODO: redirects
40}
41
42impl Default for ClientOptions {
43    fn default() -> Self {
44        Self {
45            base_url: None,
46            user_agent: None,
47            default_headers: vec![],
48            caching_behavior: CachingBehavior::default(),
49            use_default_proxy: true,
50            use_cookies: true,
51            follow_redirects: true,
52            max_response_buffer_size: None,
53            request_timeout: None,
54            ignore_certificate_errors: false,
55        }
56    }
57}