pub struct HttpOptions {
pub allow_insecure: bool,
pub follow_redirects: bool,
pub max_redirects: usize,
pub timeout: Duration,
pub max_body_size: usize,
pub block_private_ips: bool,
pub user_agent: String,
pub headers: Vec<(String, String)>,
}Expand description
Configuration for HTTP requests.
Fields§
§allow_insecure: boolAllow insecure HTTPS connections (self-signed certs).
Security Warning: Enabling this allows man-in-the-middle attacks. Only use for testing or when connecting to known self-signed services.
follow_redirects: boolFollow HTTP redirects
max_redirects: usizeMaximum number of redirects to follow
timeout: DurationRequest timeout
max_body_size: usizeMaximum response body size in bytes.
Responses larger than this will be truncated to prevent memory exhaustion. Default: 10 MB.
block_private_ips: boolBlock requests to private/internal IP addresses (SSRF protection).
When enabled, requests to localhost, private networks (10.x, 172.16-31.x, 192.168.x), link-local addresses, and cloud metadata endpoints (169.254.x) are blocked. Default: true.
user_agent: StringUser-Agent header
headers: Vec<(String, String)>Additional headers to send
Implementations§
Source§impl HttpOptions
impl HttpOptions
Sourcepub fn allow_insecure(self, allow: bool) -> Self
pub fn allow_insecure(self, allow: bool) -> Self
Set whether to allow insecure HTTPS connections.
Sourcepub fn follow_redirects(self, follow: bool) -> Self
pub fn follow_redirects(self, follow: bool) -> Self
Set whether to follow redirects.
Sourcepub fn max_redirects(self, max: usize) -> Self
pub fn max_redirects(self, max: usize) -> Self
Set the maximum number of redirects to follow.
Sourcepub fn max_body_size(self, size: usize) -> Self
pub fn max_body_size(self, size: usize) -> Self
Set the maximum response body size in bytes.
Responses larger than this will be truncated.
Sourcepub fn block_private_ips(self, block: bool) -> Self
pub fn block_private_ips(self, block: bool) -> Self
Set whether to block requests to private/internal IP addresses.
Security Note: Disabling this exposes your application to SSRF attacks if URLs come from untrusted sources.
Sourcepub fn user_agent(self, user_agent: impl Into<String>) -> Self
pub fn user_agent(self, user_agent: impl Into<String>) -> Self
Set the User-Agent header.
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