diff --git a/.changelog/1724090349.md b/.changelog/1724090349.md new file mode 100644 index 0000000000..e0dee47567 --- /dev/null +++ b/.changelog/1724090349.md @@ -0,0 +1,12 @@ +--- +applies_to: +- client +authors: +- aajtodd +references: +- smithy-rs#1925 +breaking: false +new_feature: false +bug_fix: false +--- +Backport connection poisoning to hyper 1.x support diff --git a/rust-runtime/Cargo.lock b/rust-runtime/Cargo.lock index 64830d9a96..392f485b90 100644 --- a/rust-runtime/Cargo.lock +++ b/rust-runtime/Cargo.lock @@ -404,7 +404,7 @@ dependencies = [ [[package]] name = "aws-smithy-experimental" -version = "0.1.3" +version = "0.1.4" dependencies = [ "aws-smithy-async 1.2.1", "aws-smithy-runtime 1.6.3", @@ -412,7 +412,7 @@ dependencies = [ "aws-smithy-types 1.2.2", "h2 0.4.5", "http 1.1.0", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-rustls 0.27.2", "hyper-util", "once_cell", @@ -1862,9 +1862,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -1904,7 +1904,7 @@ checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-util", "rustls 0.23.10", "rustls-native-certs 0.7.0", @@ -1916,16 +1916,16 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.3.1", + "hyper 1.4.1", "pin-project-lite", "socket2", "tokio", diff --git a/rust-runtime/aws-smithy-experimental/Cargo.toml b/rust-runtime/aws-smithy-experimental/Cargo.toml index b9486c1fcb..03a12fc9b2 100644 --- a/rust-runtime/aws-smithy-experimental/Cargo.toml +++ b/rust-runtime/aws-smithy-experimental/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws-smithy-experimental" -version = "0.1.3" +version = "0.1.4" authors = ["AWS Rust SDK Team "] description = "Experiments for the smithy-rs ecosystem" edition = "2021" @@ -15,10 +15,11 @@ crypto-aws-lc-fips = ["rustls/fips"] [dependencies] aws-smithy-types = { path = "../aws-smithy-types", features = ["http-body-1-x"] } aws-smithy-runtime-api = { features = ["client", "http-1x"], path = "../aws-smithy-runtime-api" } +aws-smithy-runtime = { features = ["client"], path = "../aws-smithy-runtime" } aws-smithy-async = { path = "../aws-smithy-async" } hyper = { version = "1", features = ["client", "http1", "http2"] } pin-project-lite = "0.2.13" -hyper-util = "0.1.3" +hyper-util = "0.1.7" http = "1" tokio = "1" hyper-rustls = { version = "0.27", features = ["http2", "http1", "native-tokio", "tls12"], default-features = false } diff --git a/rust-runtime/aws-smithy-experimental/src/hyper_1_0.rs b/rust-runtime/aws-smithy-experimental/src/hyper_1_0.rs index 81588fdebb..82253dc1c8 100644 --- a/rust-runtime/aws-smithy-experimental/src/hyper_1_0.rs +++ b/rust-runtime/aws-smithy-experimental/src/hyper_1_0.rs @@ -5,7 +5,9 @@ use aws_smithy_async::future::timeout::TimedOutError; use aws_smithy_async::rt::sleep::{default_async_sleep, AsyncSleep, SharedAsyncSleep}; +use aws_smithy_runtime::client::http::connection_poisoning::CaptureSmithyConnection; use aws_smithy_runtime_api::box_error::BoxError; +use aws_smithy_runtime_api::client::connection::ConnectionMetadata; use aws_smithy_runtime_api::client::connector_metadata::ConnectorMetadata; use aws_smithy_runtime_api::client::dns::ResolveDns; use aws_smithy_runtime_api::client::http::{ @@ -24,11 +26,13 @@ use aws_smithy_types::error::display::DisplayErrorContext; use aws_smithy_types::retry::ErrorKind; use client::connect::Connection; use h2::Reason; -use http::Uri; +use http::{Extensions, Uri}; use hyper::rt::{Read, Write}; use hyper_util::client::legacy as client; use hyper_util::client::legacy::connect::dns::Name; -use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::{ + capture_connection, CaptureConnection, Connect, HttpInfo, +}; use hyper_util::rt::TokioExecutor; use rustls::crypto::CryptoProvider; use std::borrow::Cow; @@ -400,7 +404,6 @@ impl fmt::Debug for Adapter { } } -/* /// Extract a smithy connection from a hyper CaptureConnection fn extract_smithy_connection(capture_conn: &CaptureConnection) -> Option { let capture_conn = capture_conn.clone(); @@ -425,7 +428,7 @@ fn extract_smithy_connection(capture_conn: &CaptureConnection) -> Option HttpConnector for Adapter where @@ -437,19 +440,19 @@ where C::Error: Into, { fn call(&self, request: HttpRequest) -> HttpConnectorFuture { - let request = match request.try_into_http1x() { + let mut request = match request.try_into_http1x() { Ok(request) => request, Err(err) => { return HttpConnectorFuture::ready(Err(ConnectorError::user(err.into()))); } }; - /*let capture_connection = capture_connection(&mut request); + let capture_connection = capture_connection(&mut request); if let Some(capture_smithy_connection) = request.extensions().get::() { capture_smithy_connection .set_connection_retriever(move || extract_smithy_connection(&capture_connection)); - }*/ + } let mut client = self.client.clone(); use tower::Service; let fut = client.call(request);