Skip to content

Commit aa41790

Browse files
committed
feat: lambda_http body support for byte stream
1 parent 18697d8 commit aa41790

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

rust-runtime/aws-smithy-http/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ tracing = "0.1"
2929
# We are using hyper for our streaming body implementation, but this is an internal detail.
3030
hyper = "0.14.12"
3131

32+
# For support streaming lambda_http::Body
33+
lambda_http = "0.6.0"
34+
3235
# ByteStream internals
3336
futures-core = "0.3.14"
3437
tokio = { version = "1.6", optional = true }

rust-runtime/aws-smithy-http/src/body.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,22 @@ impl From<hyper::Body> for SdkBody {
250250
}
251251
}
252252

253+
impl From<lambda_http::Body> for SdkBody {
254+
fn from(body: lambda_http::Body) -> Self {
255+
let hyper_body = match body {
256+
lambda_http::Body::Empty => hyper::Body::empty(),
257+
lambda_http::Body::Text(s) => hyper::Body::from(s),
258+
lambda_http::Body::Binary(v) => hyper::Body::from(v),
259+
};
260+
261+
SdkBody {
262+
inner: Inner::Streaming { inner: hyper_body },
263+
rebuild: None,
264+
callbacks: Vec::new(),
265+
}
266+
}
267+
}
268+
253269
impl From<Vec<u8>> for SdkBody {
254270
fn from(data: Vec<u8>) -> Self {
255271
Self::from(Bytes::from(data))

rust-runtime/aws-smithy-http/src/byte_stream.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,12 @@ impl From<hyper::Body> for ByteStream {
445445
}
446446
}
447447

448+
impl From<lambda_http::Body> for ByteStream {
449+
fn from(input: lambda_http::Body) -> Self {
450+
ByteStream::new(SdkBody::from(input))
451+
}
452+
}
453+
448454
#[derive(Debug)]
449455
pub struct Error(Box<dyn StdError + Send + Sync + 'static>);
450456

0 commit comments

Comments
 (0)