From d491881d3d7bbee5bfff509a9bad654e8d7306e4 Mon Sep 17 00:00:00 2001 From: Luis Moreno Date: Sat, 2 Dec 2023 12:39:49 -0400 Subject: [PATCH] chore: use same feature --- actix-tls/CHANGES.md | 4 ++++ actix-tls/Cargo.toml | 5 +++-- actix-tls/src/connect/uri.rs | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index 295d150b82..0192cac4dc 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -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. diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index 7d0ebfa508..08d9530b95 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-tls" -version = "3.1.1" +version = "3.2.0" authors = [ "Nikolay Kim ", "Rob Ede ", @@ -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 } diff --git a/actix-tls/src/connect/uri.rs b/actix-tls/src/connect/uri.rs index b1c7f0fec7..40aa36f4a7 100644 --- a/actix-tls/src/connect/uri.rs +++ b/actix-tls/src/connect/uri.rs @@ -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 { + 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 { match scheme {