Skip to content
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: expand use of chunked content encoding #1018

Closed
wants to merge 10 commits into from

Conversation

lauzadis
Copy link
Contributor

@lauzadis lauzadis commented Dec 26, 2023

If a streaming body with an undefined content length is provided, upload it with chunked to ensure the hash can be properly calculated. This reduces occurrences of exceptions claiming Stream must be replayable to calculate a body hash

Issue #

Addresses an issue in awslabs/aws-sdk-kotlin#1157

Description of changes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lauzadis lauzadis requested a review from a team as a code owner December 26, 2023 17:06
Copy link
Contributor

@aajtodd aajtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems ok but I don't think it addresses the underlying issue. If a user submits a request without a flexible checksum this would still fail right? I think we need to solve that because it looks like the request in the issue without a checksum should succeed as well unless I'm missing something.

@@ -163,6 +165,12 @@ public class AwsHttpSigner(private val config: Config) : HttpSigner {
HashSpecification.StreamingAws4HmacSha256Payload
}
}
request.headers["x-amz-checksum-sha256"] != null -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Should probably be a constant value somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: Needs tests

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@lauzadis lauzadis changed the title feat: re-use flexible checksums SHA256 feat: expand use of aws-chunked content encoding Dec 28, 2023
@lauzadis lauzadis changed the title feat: expand use of aws-chunked content encoding feat: expand use of chunked content encoding Dec 28, 2023
Comment on lines +46 to +47
get() = (this is HttpBody.SourceContent || this is HttpBody.ChannelContent) &&
(isOneShot || (contentLength?.compareTo(AWS_CHUNKED_THRESHOLD) ?: 0) > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: ?.compareTo works but is pretty verbose and still requires null-coalescing the value. Shorter would just be:

(contentLength ?: 0 > AWS_CHUNKED_THRESHOLD)

Same comment applies below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants