chore: use same feature

This commit is contained in:
Luis Moreno 2023-12-02 12:39:49 -04:00
parent 923a443950
commit d491881d3d
3 changed files with 21 additions and 2 deletions

View File

@ -2,6 +2,10 @@
## Unreleased
## 3.2.0
- Added support to `http` crate version `1.0`.
## 3.1.1
- Fix `rustls` v0.21 version requirement.

View File

@ -1,6 +1,6 @@
[package]
name = "actix-tls"
version = "3.1.1"
version = "3.2.0"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
@ -56,7 +56,7 @@ rustls-0_21 = ["tokio-rustls-024", "webpki-roots-025"]
native-tls = ["tokio-native-tls"]
# support http::Uri as connect address
uri = ["http"]
uri = ["http", "http-1"]
[dependencies]
actix-rt = { version = "2.2", default-features = false }
@ -72,6 +72,7 @@ tracing = { version = "0.1.30", default-features = false, features = ["log"] }
# uri
http = { version = "0.2.3", optional = true }
http-1 = { package = "http", version = "1", optional = true }
# openssl
tls-openssl = { package = "openssl", version = "0.10.55", optional = true }

View File

@ -1,4 +1,5 @@
use http::Uri;
use http_1::Uri as Http1Uri;
use super::Host;
@ -15,6 +16,19 @@ impl Host for Uri {
}
}
impl Host for Http1Uri {
fn hostname(&self) -> &str {
self.host().unwrap_or("")
}
fn port(&self) -> Option<u16> {
match self.port_u16() {
Some(port) => Some(port),
None => scheme_to_port(self.scheme_str()),
}
}
}
// Get port from well-known URL schemes.
fn scheme_to_port(scheme: Option<&str>) -> Option<u16> {
match scheme {