1 // Copyright (c) 2023 Huawei Device Co., Ltd. 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 //! Connector configure module. 15 16 #[cfg(all(target_os = "linux", feature = "ylong_base", feature = "__c_openssl"))] 17 use super::FchownConfig; 18 use crate::util::proxy::Proxies; 19 use crate::Timeout; 20 21 #[derive(Default)] 22 pub(crate) struct ConnectorConfig { 23 pub(crate) proxies: Proxies, 24 pub(crate) timeout: Timeout, 25 26 #[cfg(all(target_os = "linux", feature = "ylong_base", feature = "__c_openssl"))] 27 pub(crate) fchown: Option<FchownConfig>, 28 29 #[cfg(feature = "__tls")] 30 pub(crate) tls: crate::util::TlsConfig, 31 } 32 33 #[cfg(test)] 34 mod ut_connector_config { 35 use ylong_http::request::uri::Uri; 36 37 use crate::util::config::ConnectorConfig; 38 39 /// UT test cases for `ConnectorConfig::default`. 40 /// 41 /// # Brief 42 /// 1. Creates a `ConnectorConfig` by calling `ConnectorConfig::default`. 43 /// 2. Checks if the result is as expected. 44 #[test] ut_connector_config_default()45 fn ut_connector_config_default() { 46 let config = ConnectorConfig::default(); 47 let uri = Uri::from_bytes(b"http://127.0.0.1").unwrap(); 48 assert!(config.proxies.match_proxy(&uri).is_none()) 49 } 50 } 51