implement https_only flag
This commit is contained in:
committed by
Martin Algesten
parent
06743da5de
commit
aced0d9b6a
17
src/agent.rs
17
src/agent.rs
@@ -54,6 +54,7 @@ pub(crate) struct AgentConfig {
|
||||
pub timeout_read: Option<Duration>,
|
||||
pub timeout_write: Option<Duration>,
|
||||
pub timeout: Option<Duration>,
|
||||
pub https_only: bool,
|
||||
pub no_delay: bool,
|
||||
pub redirects: u32,
|
||||
pub redirect_auth_headers: RedirectAuthHeaders,
|
||||
@@ -239,6 +240,7 @@ impl AgentBuilder {
|
||||
timeout_read: None,
|
||||
timeout_write: None,
|
||||
timeout: None,
|
||||
https_only: false,
|
||||
no_delay: true,
|
||||
redirects: 5,
|
||||
redirect_auth_headers: RedirectAuthHeaders::Never,
|
||||
@@ -293,6 +295,21 @@ impl AgentBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Enforce the client to only perform HTTPS requests.
|
||||
/// This setting also makes the client refuse HTTPS to HTTP redirects.
|
||||
/// Default is false
|
||||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// let agent = ureq::AgentBuilder::new()
|
||||
/// .https_only(true)
|
||||
/// .build();
|
||||
/// ```
|
||||
pub fn https_only(mut self, enforce: bool) -> Self {
|
||||
self.config.https_only = enforce;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum number of connections allowed in the connection pool.
|
||||
/// By default, this is set to 100. Setting this to zero would disable
|
||||
/// connection pooling.
|
||||
|
||||
Reference in New Issue
Block a user