|
| 1 | +use http_type::HTTPS_LOWERCASE; |
| 2 | + |
1 | 3 | use crate::*; |
2 | 4 |
|
3 | 5 | /// Blanket implementation for AsyncReadWrite trait. |
@@ -100,10 +102,10 @@ impl HttpRequest { |
100 | 102 | /// |
101 | 103 | /// # Returns |
102 | 104 | /// |
103 | | - /// - `Protocol` - The HTTP protocol. |
| 105 | + /// - `String` - The HTTP protocol. |
104 | 106 | #[inline(always)] |
105 | | - pub(crate) fn get_protocol(config: &Config) -> Protocol { |
106 | | - config.url_obj.protocol.clone() |
| 107 | + pub(crate) fn get_protocol(config: &Config) -> String { |
| 108 | + config.url_obj.protocol.to_lowercase() |
107 | 109 | } |
108 | 110 |
|
109 | 111 | /// Gets the HTTP methods. |
@@ -567,8 +569,8 @@ impl HttpRequest { |
567 | 569 | if port != 0 { |
568 | 570 | return port; |
569 | 571 | } |
570 | | - let protocol: Protocol = Self::get_protocol(config); |
571 | | - protocol.get_port() |
| 572 | + let protocol: String = Self::get_protocol(config); |
| 573 | + Protocol::get_port(&protocol) |
572 | 574 | } |
573 | 575 |
|
574 | 576 | /// Establishes a connection stream to the specified host and port. |
@@ -612,7 +614,7 @@ impl HttpRequest { |
612 | 614 | .set_write_timeout(Some(timeout)) |
613 | 615 | .map_err(|error| RequestError::Request(error.to_string()))?; |
614 | 616 | let stream: Result<Box<dyn ReadWrite>, RequestError> = |
615 | | - if Self::get_protocol(&config).is_https() { |
| 617 | + if Self::get_protocol(&config) == HTTPS_LOWERCASE { |
616 | 618 | match self.tmp.clone().read() { |
617 | 619 | Ok(tmp) => { |
618 | 620 | let roots: RootCertStore = tmp.root_cert.clone(); |
@@ -647,7 +649,9 @@ impl HttpRequest { |
647 | 649 | let timeout: Duration = Duration::from_millis( |
648 | 650 | self.config |
649 | 651 | .read() |
650 | | - .map_or(DEFAULT_TIMEOUT, |config| config.timeout), |
| 652 | + .map_or(DEFAULT_HIGH_SECURITY_HTTP_READ_TIMEOUT_MS, |config| { |
| 653 | + config.timeout |
| 654 | + }), |
651 | 655 | ); |
652 | 656 | match proxy_config.proxy_type { |
653 | 657 | ProxyType::Http | ProxyType::Https => { |
@@ -744,7 +748,7 @@ impl HttpRequest { |
744 | 748 | .config |
745 | 749 | .read() |
746 | 750 | .map_or(Config::default(), |config| config.clone()); |
747 | | - if Self::get_protocol(&config).is_https() { |
| 751 | + if Self::get_protocol(&config) == HTTPS_LOWERCASE { |
748 | 752 | match self.tmp.clone().read() { |
749 | 753 | Ok(tmp) => { |
750 | 754 | let roots: RootCertStore = tmp.root_cert.clone(); |
@@ -894,7 +898,7 @@ impl HttpRequest { |
894 | 898 | .config |
895 | 899 | .read() |
896 | 900 | .map_or(Config::default(), |config| config.clone()); |
897 | | - if Self::get_protocol(&config).is_https() { |
| 901 | + if Self::get_protocol(&config) == HTTPS_LOWERCASE { |
898 | 902 | match self.tmp.clone().read() { |
899 | 903 | Ok(tmp) => { |
900 | 904 | let roots: RootCertStore = tmp.root_cert.clone(); |
@@ -1184,7 +1188,7 @@ impl HttpRequest { |
1184 | 1188 | let tcp_stream: AsyncTcpStream = AsyncTcpStream::connect(host_port.clone()) |
1185 | 1189 | .await |
1186 | 1190 | .map_err(|error| RequestError::Request(error.to_string()))?; |
1187 | | - if Self::get_protocol(&config).is_https() { |
| 1191 | + if Self::get_protocol(&config) == HTTPS_LOWERCASE { |
1188 | 1192 | let roots: RootCertStore = { |
1189 | 1193 | match self.tmp.clone().read() { |
1190 | 1194 | Ok(tmp) => tmp.root_cert.clone(), |
@@ -1329,7 +1333,7 @@ impl HttpRequest { |
1329 | 1333 | .config |
1330 | 1334 | .read() |
1331 | 1335 | .map_or(Config::default(), |config| config.clone()); |
1332 | | - if Self::get_protocol(&config).is_https() { |
| 1336 | + if Self::get_protocol(&config) == HTTPS_LOWERCASE { |
1333 | 1337 | let roots: RootCertStore = { |
1334 | 1338 | match self.tmp.clone().read() { |
1335 | 1339 | Ok(tmp) => tmp.root_cert.clone(), |
@@ -1497,7 +1501,7 @@ impl HttpRequest { |
1497 | 1501 | .config |
1498 | 1502 | .read() |
1499 | 1503 | .map_or(Config::default(), |config| config.clone()); |
1500 | | - if Self::get_protocol(&config).is_https() { |
| 1504 | + if Self::get_protocol(&config) == HTTPS_LOWERCASE { |
1501 | 1505 | let roots: RootCertStore = { |
1502 | 1506 | match self.tmp.clone().read() { |
1503 | 1507 | Ok(tmp) => tmp.root_cert.clone(), |
|
0 commit comments