-
Notifications
You must be signed in to change notification settings - Fork 193
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
feat(aws-smithy-types): Impl http-body-1.0 Body for SdkBody #3380
Conversation
c3359a5
to
5e8334a
Compare
/// Construct an `SdkBody` from a type that implements [`hyper_1_0::body::Body<Data = Bytes>`](hyper_1_0::body::Body) | ||
pub fn from_hyper_1_x<T, E>(body: T) -> Self | ||
where | ||
T: hyper_1_0::body::Body<Data = Bytes, Error = E> + Send + Sync + 'static, | ||
E: Into<Error> + 'static, | ||
{ | ||
SdkBody { | ||
bytes_contents: None, | ||
inner: super::Inner::Dyn { | ||
inner: super::BoxBody::HttpBody10(http_body_util::combinators::BoxBody::new( | ||
body.map_err(Into::into), | ||
)), | ||
}, | ||
rebuild: None, | ||
} | ||
} | ||
} |
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.
how does this type differ from HttpBody
? aren't they kinda the same ? I don't think we necessarily want a hyper-specific constructor.
self: Pin<&mut Self>, | ||
cx: &mut Context<'_>, | ||
) -> Poll<Option<Result<http_body_1_0::Frame<Bytes>, Error>>> { | ||
// There has got to be a way to simplify this matching matchy match |
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.
yeah you want the ready!
macro
Poll::Pending => return Poll::Pending, | ||
Poll::Ready(maybe_ready) => match maybe_ready { | ||
None => return Poll::Ready(None), | ||
Some(result) => match result { | ||
Err(err) => return Poll::Ready(Some(Err(err))), | ||
Ok(bytes) => return Poll::Ready(Some(Ok(http_body_1_0::Frame::data(bytes)))), | ||
}, | ||
}, | ||
} | ||
} |
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.
this doesn't handle trailers correctly. I'd start by adding a test case involving trailers (that should fail), then go from there.
@@ -248,7 +248,7 @@ pin_project! { | |||
/// 3. **From an `SdkBody` directly**: For more advanced / custom use cases, a ByteStream can be created directly | |||
/// from an SdkBody. **When created from an SdkBody, care must be taken to ensure retriability.** An SdkBody is retryable | |||
/// when constructed from in-memory data or when using [`SdkBody::retryable`](crate::body::SdkBody::retryable). | |||
/// ```no_run |
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.
was this required?
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.
It might have been something about the host I pulled the repo down on, but it was still compiling for some reason. This was the only way I could get it to pass the initial build (locally)
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.
a good start—needs to handle trailers + include tests.
adb22b8
to
0d646b7
Compare
0d646b7
to
e34dbde
Compare
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.
LGTM!
Co-authored-by: John DiSanti <[email protected]>
Motivation and Context
A step towards moving to http-1.0
awslabs/aws-sdk-rust#1046
(Russell): This is a minimal implementation of
http-body = 1
. It isn't maximally efficient since even if we were given a 1x body, we convert it back and forth first. This is a first step.Description
Implements http-body-1.0 Body trait for SdkBody.
Testing
Regular CI
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.