diff --git a/lambda-events/Cargo.toml b/lambda-events/Cargo.toml index ca5fa1a8..e3653819 100644 --- a/lambda-events/Cargo.toml +++ b/lambda-events/Cargo.toml @@ -17,9 +17,9 @@ edition = "2021" [dependencies] base64 = "0.21" -http = { version = "0.2", optional = true } -http-body = { version = "0.4", optional = true } -http-serde = { version = "^1", optional = true } +http = { version = "1.0", optional = true } +http-body = { version = "1.0", optional = true } +http-serde = { version = "2.0", optional = true } serde = { version = "^1", features = ["derive"] } serde_with = { version = "^3", features = ["json"], optional = true } serde_json = "^1" diff --git a/lambda-events/src/encodings/http.rs b/lambda-events/src/encodings/http.rs index effb48f4..1cb10c81 100644 --- a/lambda-events/src/encodings/http.rs +++ b/lambda-events/src/encodings/http.rs @@ -218,25 +218,6 @@ impl HttpBody for Body { type Data = Bytes; type Error = super::Error; - fn poll_data( - self: Pin<&mut Self>, - _cx: &mut std::task::Context<'_>, - ) -> Poll>> { - let body = take(self.get_mut()); - Poll::Ready(match body { - Body::Empty => None, - Body::Text(s) => Some(Ok(s.into())), - Body::Binary(b) => Some(Ok(b.into())), - }) - } - - fn poll_trailers( - self: Pin<&mut Self>, - _cx: &mut std::task::Context<'_>, - ) -> Poll, Self::Error>> { - Poll::Ready(Ok(None)) - } - fn is_end_stream(&self) -> bool { matches!(self, Body::Empty) } @@ -248,6 +229,18 @@ impl HttpBody for Body { Body::Binary(ref b) => SizeHint::with_exact(b.len() as u64), } } + + fn poll_frame( + self: Pin<&mut Self>, + _cx: &mut std::task::Context<'_>, + ) -> Poll, Self::Error>>> { + let body = take(self.get_mut()); + Poll::Ready(match body { + Body::Empty => None, + Body::Text(s) => Some(Ok(http_body::Frame::data(s.into()))), + Body::Binary(b) => Some(Ok(http_body::Frame::data(b.into()))), + }) + } } #[cfg(test)] diff --git a/lambda-extension/Cargo.toml b/lambda-extension/Cargo.toml index 5d9d54b4..9aef0e6a 100644 --- a/lambda-extension/Cargo.toml +++ b/lambda-extension/Cargo.toml @@ -17,13 +17,17 @@ readme = "README.md" async-stream = "0.3" bytes = "1.0" chrono = { version = "0.4", features = ["serde"] } -http = "0.2" -hyper = { version = "0.14.20", features = ["http1", "client", "server", "stream", "runtime"] } +http = "1.0" +hyper = { version = "1.0", features = ["http1", "client", "server"] } lambda_runtime_api_client = { version = "0.8", path = "../lambda-runtime-api-client" } serde = { version = "1", features = ["derive"] } serde_json = "^1" tracing = { version = "0.1", features = ["log"] } -tokio = { version = "1.0", features = ["macros", "io-util", "sync", "rt-multi-thread"] } +tokio = { version = "1.0", features = [ + "macros", + "io-util", + "sync", + "rt-multi-thread", +] } tokio-stream = "0.1.2" tower = { version = "0.4", features = ["make", "util"] } - diff --git a/lambda-http/Cargo.toml b/lambda-http/Cargo.toml index fc93d88f..74590fb3 100644 --- a/lambda-http/Cargo.toml +++ b/lambda-http/Cargo.toml @@ -26,9 +26,9 @@ alb = [] base64 = "0.21" bytes = "1.4" futures = "0.3" -http = "0.2" -http-body = "0.4" -hyper = "0.14" +http = "1.0" +http-body = "1.0" +hyper = "1.0" lambda_runtime = { path = "../lambda-runtime", version = "0.8.3" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/lambda-runtime-api-client/Cargo.toml b/lambda-runtime-api-client/Cargo.toml index ae3e0f70..ad2d0f1b 100644 --- a/lambda-runtime-api-client/Cargo.toml +++ b/lambda-runtime-api-client/Cargo.toml @@ -4,7 +4,7 @@ version = "0.8.0" edition = "2021" authors = [ "David Calavera ", - "Harold Sun " + "Harold Sun ", ] description = "AWS Lambda Runtime interaction API" license = "Apache-2.0" @@ -14,7 +14,15 @@ keywords = ["AWS", "Lambda", "API"] readme = "README.md" [dependencies] -http = "0.2" -hyper = { version = "0.14.20", features = ["http1", "client", "stream", "tcp"] } +http = "1.0" +http-body = "1.0" +http-body-util = "0.1" +hyper = { version = "1.0", features = ["http1", "client"] } +hyper-util = { version = "0.1.1", features = [ + "client", + "client-legacy", + "http1", + "tokio", +] } tower-service = "0.3" tokio = { version = "1.0", features = ["io-util"] } diff --git a/lambda-runtime-api-client/src/lib.rs b/lambda-runtime-api-client/src/lib.rs index 4b082aba..c3ac706b 100644 --- a/lambda-runtime-api-client/src/lib.rs +++ b/lambda-runtime-api-client/src/lib.rs @@ -5,12 +5,8 @@ //! This crate includes a base HTTP client to interact with //! the AWS Lambda Runtime API. use http::{uri::PathAndQuery, uri::Scheme, Request, Response, Uri}; -use hyper::{ - client::{connect::Connection, HttpConnector}, - Body, -}; +use hyper_util::client::legacy::connect::{Connection, HttpConnector}; use std::{convert::TryInto, fmt::Debug}; -use tokio::io::{AsyncRead, AsyncWrite}; use tower_service::Service; const USER_AGENT_HEADER: &str = "User-Agent"; @@ -26,7 +22,7 @@ pub struct Client { /// The runtime API URI pub base: Uri, /// The client that manages the API connections - pub client: hyper::Client, + pub client: hyper_util::client::legacy::Client, } impl Client { @@ -41,11 +37,11 @@ impl Client { impl Client where - C: hyper::client::connect::Connect + Sync + Send + Clone + 'static, + C: hyper_util::client::legacy::connect::Connect + Sync + Send + Clone + 'static, { /// Send a given request to the Runtime API. /// Use the client's base URI to ensure the API endpoint is correct. - pub async fn call(&self, req: Request) -> Result, Error> { + pub async fn call(&self, req: Request) -> Result, Error> { let req = self.set_origin(req)?; let response = self.client.request(req).await?; Ok(response) @@ -53,7 +49,7 @@ where /// Create a new client with a given base URI and HTTP connector. pub fn with(base: Uri, connector: C) -> Self { - let client = hyper::Client::builder() + let client = hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new()) .http1_max_buf_size(1024 * 1024) .build(connector); Self { base, client } @@ -83,7 +79,7 @@ where } /// Builder implementation to construct any Runtime API clients. -pub struct ClientBuilder = hyper::client::HttpConnector> { +pub struct ClientBuilder = HttpConnector> { connector: C, uri: Option, } @@ -93,7 +89,7 @@ where C: Service + Clone + Send + Sync + Unpin + 'static, >::Future: Unpin + Send, >::Error: Into>, - >::Response: AsyncRead + AsyncWrite + Connection + Unpin + Send + 'static, + >::Response: Connection + Unpin + Send + 'static, { /// Create a new builder with a given HTTP connector. pub fn with_connector(self, connector: C2) -> ClientBuilder @@ -101,7 +97,7 @@ where C2: Service + Clone + Send + Sync + Unpin + 'static, >::Future: Unpin + Send, >::Error: Into>, - >::Response: AsyncRead + AsyncWrite + Connection + Unpin + Send + 'static, + >::Response: Connection + Unpin + Send + 'static, { ClientBuilder { connector, @@ -116,7 +112,10 @@ where } /// Create the new client to interact with the Runtime API. - pub fn build(self) -> Result, Error> { + pub fn build(self) -> Result, Error> + where + C: hyper_util::client::legacy::connect::Connect + Sync + Send + Clone + 'static, + { let uri = match self.uri { Some(uri) => uri, None => { diff --git a/lambda-runtime/Cargo.toml b/lambda-runtime/Cargo.toml index 335b5482..49ec9ede 100644 --- a/lambda-runtime/Cargo.toml +++ b/lambda-runtime/Cargo.toml @@ -35,7 +35,7 @@ futures = "0.3" serde = { version = "1", features = ["derive", "rc"] } serde_json = "^1" bytes = "1.0" -http = "0.2" +http = "1.0" async-stream = "0.3" tracing = { version = "0.1.37", features = ["log"] } tower = { version = "0.4", features = ["util"] }