From a1c7e6908a26e10f6e1f23a51721664b5e2d838d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 17 May 2026 02:53:53 +0900 Subject: chore(style): cargo fmt --- crates/shirabe/src/util/http/request_proxy.rs | 40 +++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/util/http/request_proxy.rs') diff --git a/crates/shirabe/src/util/http/request_proxy.rs b/crates/shirabe/src/util/http/request_proxy.rs index 1405a32..5bbf5ce 100644 --- a/crates/shirabe/src/util/http/request_proxy.rs +++ b/crates/shirabe/src/util/http/request_proxy.rs @@ -2,9 +2,9 @@ use indexmap::IndexMap; use shirabe_php_shim::{ - curl_version, PhpMixed, CURLAUTH_BASIC, CURL_VERSION_HTTPS_PROXY, CURLOPT_NOPROXY, - CURLOPT_PROXY, CURLOPT_PROXY_CAINFO, CURLOPT_PROXY_CAPATH, CURLOPT_PROXYAUTH, - CURLOPT_PROXYUSERPWD, InvalidArgumentException, + CURL_VERSION_HTTPS_PROXY, CURLAUTH_BASIC, CURLOPT_NOPROXY, CURLOPT_PROXY, CURLOPT_PROXY_CAINFO, + CURLOPT_PROXY_CAPATH, CURLOPT_PROXYAUTH, CURLOPT_PROXYUSERPWD, InvalidArgumentException, + PhpMixed, curl_version, }; use crate::downloader::transport_exception::TransportException; @@ -21,8 +21,18 @@ pub struct RequestProxy { } impl RequestProxy { - pub fn new(url: Option, auth: Option, context_options: Option, status: Option) -> Self { - Self { url, auth, context_options, status } + pub fn new( + url: Option, + auth: Option, + context_options: Option, + status: Option, + ) -> Self { + Self { + url, + auth, + context_options, + status, + } } pub fn none() -> Self { @@ -37,13 +47,22 @@ impl RequestProxy { self.context_options.as_ref() } - pub fn get_curl_options(&self, ssl_options: &IndexMap) -> Result, TransportException> { + pub fn get_curl_options( + &self, + ssl_options: &IndexMap, + ) -> Result, TransportException> { if self.is_secure() && !self.supports_secure_proxy() { - return Err(TransportException::new("Cannot use an HTTPS proxy. PHP >= 7.3 and cUrl >= 7.52.0 are required.".to_string())); + return Err(TransportException::new( + "Cannot use an HTTPS proxy. PHP >= 7.3 and cUrl >= 7.52.0 are required." + .to_string(), + )); } let mut options: IndexMap = IndexMap::new(); - options.insert(CURLOPT_PROXY, PhpMixed::String(self.url.as_deref().unwrap_or("").to_string())); + options.insert( + CURLOPT_PROXY, + PhpMixed::String(self.url.as_deref().unwrap_or("").to_string()), + ); if self.url.is_some() { options.insert(CURLOPT_NOPROXY, PhpMixed::String(String::new())); @@ -100,7 +119,10 @@ impl RequestProxy { return false; } - let features = version.get("features").and_then(|v| v.as_int()).unwrap_or(0); + let features = version + .get("features") + .and_then(|v| v.as_int()) + .unwrap_or(0); (features & CURL_VERSION_HTTPS_PROXY) != 0 } } -- cgit v1.3.1