pub struct HttpOptions { /* private fields */ }Expand description
Configuration options for HTTP client used in schema retrieval.
This struct provides builder-style methods to configure the HTTP client used when fetching external schemas via HTTP/HTTPS.
§Example
use std::time::Duration;
use jsonschema::HttpOptions;
let http_options = HttpOptions::new()
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(30))
.danger_accept_invalid_certs(false);Implementations§
Source§impl HttpOptions
impl HttpOptions
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set the timeout for the connect phase of a connection.
This controls how long the client will wait to establish a connection to the remote server.
§Example
use std::time::Duration;
use jsonschema::HttpOptions;
let options = HttpOptions::new()
.connect_timeout(Duration::from_secs(10));Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Set the total timeout for the entire request.
This includes connection time, any redirects, and reading the response body.
Note: If timeout is smaller than connect_timeout, the total timeout
takes precedence and will cap the connection attempt.
§Example
use std::time::Duration;
use jsonschema::HttpOptions;
let options = HttpOptions::new()
.timeout(Duration::from_secs(60));Sourcepub fn danger_accept_invalid_certs(self, accept: bool) -> Self
pub fn danger_accept_invalid_certs(self, accept: bool) -> Self
Controls whether to accept invalid TLS certificates.
WARNING: Setting this to true disables certificate validation,
which makes the connection vulnerable to man-in-the-middle attacks.
Only use this for testing or in controlled environments.
§Example
use jsonschema::HttpOptions;
// Not recommended for production use!
let options = HttpOptions::new()
.danger_accept_invalid_certs(true);Sourcepub fn add_root_certificate(self, path: impl Into<PathBuf>) -> Self
pub fn add_root_certificate(self, path: impl Into<PathBuf>) -> Self
Add a custom root certificate for TLS verification.
This allows you to trust a custom CA certificate in addition to the system’s root certificates.
§Example
use std::path::PathBuf;
use jsonschema::HttpOptions;
let options = HttpOptions::new()
.add_root_certificate("/path/to/ca-cert.pem");Trait Implementations§
Source§impl Clone for HttpOptions
impl Clone for HttpOptions
Source§fn clone(&self) -> HttpOptions
fn clone(&self) -> HttpOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more