Skip to content

Commit

Permalink
append h2 to ALPN instead of override
Browse files Browse the repository at this point in the history
  • Loading branch information
goatgoose committed Nov 26, 2024
1 parent 0220444 commit a6cf75a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bindings/rust/s2n-tls-hyper/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ where
/// This API creates an `HttpsConnector` using the default hyper `HttpConnector`. To use an
/// existing HTTP connector, use `HttpsConnector::new_with_http()`.
///
/// Note that the HttpsConnector will automatically attempt to negotiate HTTP/2 by overriding
/// Note that the HttpsConnector will automatically attempt to negotiate HTTP/2 by appending to
/// the ALPN extension. Any ALPN values configured on `conn_builder` with APIs like
/// `s2n_tls::config::Builder::set_application_protocol_preference()` will be ignored.
/// `s2n_tls::config::Builder::set_application_protocol_preference()` will be sent in addition
/// to "h2".
pub fn new(conn_builder: Builder) -> HttpsConnector<HttpConnector, Builder> {
let mut http = HttpConnector::new();

Expand Down Expand Up @@ -82,9 +83,10 @@ where
///
/// `HttpsConnector::new()` can be used to create the HTTP connector automatically.
///
/// Note that the HttpsConnector will automatically attempt to negotiate HTTP/2 by overriding
/// Note that the HttpsConnector will automatically attempt to negotiate HTTP/2 by appending to
/// the ALPN extension. Any ALPN values configured on `conn_builder` with APIs like
/// `s2n_tls::config::Builder::set_application_protocol_preference()` will be ignored.
/// `s2n_tls::config::Builder::set_application_protocol_preference()` will be sent in addition
/// to "h2".
pub fn new_with_http(http: Http, conn_builder: Builder) -> HttpsConnector<Http, Builder> {
Self { http, conn_builder }
}
Expand Down Expand Up @@ -128,7 +130,7 @@ where

// Attempt to negotiate HTTP/2.
let builder = connection::ModifiedBuilder::new(self.conn_builder.clone(), |conn| {
conn.set_application_protocol_preference([b"h2"])
conn.append_application_protocol_preference(b"h2")
});

let host = req.host().unwrap_or("").to_owned();
Expand Down

0 comments on commit a6cf75a

Please sign in to comment.