Skip to content

Commit

Permalink
chore: use same feature
Browse files Browse the repository at this point in the history
  • Loading branch information
morenol committed Dec 5, 2023
1 parent 923a443 commit 71aa6a3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
4 changes: 4 additions & 0 deletions actix-tls/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions actix-tls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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>",
Expand Down Expand Up @@ -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 }
Expand All @@ -70,8 +70,10 @@ tokio = "1.23.1"
tokio-util = "0.7"
tracing = { version = "0.1.30", default-features = false, features = ["log"] }

# uri
http = { version = "0.2.3", optional = true }
# http v0.3
http = { version = "0.2.3", optional = true}
# http v1
http-1 = { package = "http", version = "1", optional = true }

# openssl
tls-openssl = { package = "openssl", version = "0.10.55", optional = true }
Expand Down
17 changes: 15 additions & 2 deletions actix-tls/src/connect/uri.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use http::Uri;

use super::Host;
use http::Uri;
use http_1::Uri as Http1Uri;

impl Host for Uri {
fn hostname(&self) -> &str {
Expand All @@ -15,6 +15,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 {
Expand Down

0 comments on commit 71aa6a3

Please sign in to comment.