-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connector: enable_all_versions
with matching alpn vs features
#224
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,16 +174,22 @@ impl ConnectorBuilder<WantsProtocols1> { | |
}) | ||
} | ||
|
||
/// Enable all HTTP versions | ||
/// Enable all HTTP versions built into this library | ||
/// | ||
/// For now, this enables both HTTP 1 and 2. In the future, other supported versions | ||
/// will be enabled as well. | ||
#[cfg(all(feature = "http1", feature = "http2"))] | ||
/// For now, this could enable both HTTP 1 and 2, depending on active features. | ||
/// In the future, other supported versions will be enabled as well. | ||
#[cfg(feature = "http2")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||
Comment on lines
+181
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're going to do this, let's get rid of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, that seems like the right direction There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with not having the Making the feature combination non-breaking would require wrapping the actual inner type If a version of this fix gets merged I could create a new PR with the above solution with a new breaking return type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems reasonable, I'd be willing to merge this in order to get this improvement out provided you submit an additional PR to do the semver-breaking fix. |
||
pub fn enable_all_versions(mut self) -> ConnectorBuilder<WantsProtocols3> { | ||
self.0.tls_config.alpn_protocols = vec![b"h2".to_vec()]; | ||
#[cfg(feature = "http1")] | ||
let alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; | ||
#[cfg(not(feature = "http1"))] | ||
let alpn_protocols = vec![b"h2".to_vec()]; | ||
|
||
self.0.tls_config.alpn_protocols = alpn_protocols; | ||
ConnectorBuilder(WantsProtocols3 { | ||
inner: self.0, | ||
enable_http1: true, | ||
enable_http1: cfg!(feature = "http1"), | ||
}) | ||
} | ||
|
||
|
@@ -326,7 +332,7 @@ mod tests { | |
.build(); | ||
assert_eq!(&connector.tls_config.alpn_protocols, &[b"h2".to_vec()]); | ||
let connector = super::ConnectorBuilder::new() | ||
.with_tls_config(tls_config) | ||
.with_tls_config(tls_config.clone()) | ||
.https_only() | ||
.enable_http1() | ||
.enable_http2() | ||
|
@@ -335,5 +341,14 @@ mod tests { | |
&connector.tls_config.alpn_protocols, | ||
&[b"h2".to_vec(), b"http/1.1".to_vec()] | ||
); | ||
let connector = super::ConnectorBuilder::new() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this test is only checking the result of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, I realized this too. I locally created an additional test case for only |
||
.with_tls_config(tls_config) | ||
.https_only() | ||
.enable_all_versions() | ||
.build(); | ||
assert_eq!( | ||
&connector.tls_config.alpn_protocols, | ||
&[b"h2".to_vec(), b"http/1.1".to_vec()] | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this more explicit, like
(enabled with Cargo features)
?