Skip to content

Conversation

@ysaito1001
Copy link
Contributor

@ysaito1001 ysaito1001 commented Nov 5, 2025

Motivation and Context

This PR breaks up RequestChecksumInterceptor into two interceptors: RequestChecksumInterceptor and AwsChunkedContentEncodingInterceptor with additional code restructuring to support the upcoming aws-chunked content encoding enhancement.

Description

RequestChecksumInterceptor previously handled two distinct responsibilities:

  1. Adding checksums (body or trailer)
  2. Applying aws-chunked content encoding

This refactor extracts the second responsibility (aws-chunked logic) into AwsChunkedContentEncodingInterceptor, aiming to enable it via the dedicated trait when available in Smithy.

In addition, both interceptors now wrap bodies in modify_before_transmit instead of modify_before_signing per design requirements.

Tips for merging to feature/http-1.x

This refactor reluctantly adds http_0x constructs that will conflict with feature/http-1.x. Update these files when merging:

  • aws-inlineable/src/http_request_checksum.rs - Apply same 1.x updates as done in branch (note: test_checksum_body_is_retryable was removed as it tested a utility only used in streaming cases against non-streaming bodies)
  • aws-inlineable/src/aws_chunked.rs - Use 1.x for header names, values, and body trait methods in unit tests, as in http_request_checksum.rs
  • aws/rust-runtime/aws-runtime/src/content_encoding.rs - Needs 1.x updates
    fn size_hint(&self) -> http_body_1x::SizeHint {
        http_body_1x::SizeHint::with_exact(self.encoded_length())
    }

to

    fn size_hint(&self) -> http_body_1x::SizeHint {
        http_body_1x::SizeHint::with_exact(self.options.encoded_length())
    }

because the .encoded_length() method has been moved from AwsChunkedBody to AwsChunkedBodyOptions (due to the content-length header needing encoded length during signing but body creation deferred to
modify_before_transmit)

Testing

  • CI

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ysaito1001 ysaito1001 requested review from a team as code owners November 5, 2025 22:02
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Contributor

@landonxjames landonxjames left a comment

Choose a reason for hiding this comment

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

Looks good, a few questions, but no blockers

// This decorator must decorate after any of the following:
// - HttpRequestChecksumDecorator
// - HttpRequestCompressionDecorator
override val order: Byte = (minOf(HttpRequestChecksumDecorator.ORDER, HttpRequestCompressionDecorator.ORDER) - 1).toByte()
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want it to always run after wouldn't it be maxOf() +1? If I remember correctly higher orders run later

ex:

// Must run after the AwsPresigningDecorator so that the presignable trait is correctly added to operations
override val order: Byte = (AwsPresigningDecorator.ORDER + 1).toByte()

match self {
Self::UnsizedRequestBody => write!(
f,
"Only request bodies with a known size can be chunk-encoded."
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe ... can be aws-chunked encoded to avoid confusion with transfer-encoding: chunked?

_runtime_components: &RuntimeComponents,
cfg: &mut ConfigBag,
) -> Result<(), BoxError> {
if must_not_use_chunked_encoding(ctx.request(), cfg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since modify_before_signing will always run before this is there any point in checking must_not_use_chunked_encoding again? Is there a situation where the result there could change between signing and transmit?

/// order to correctly calculate the total size of the body accurately.
trailer_lengths: Vec<u64>,
/// Whether the aws-chunked encoding is disabled. This could occur, for instance,
/// if a user specifies a custom checksum, rendering aws-chunked encoding unnecessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

That might render it unnecessary, but I wonder if it would have performance implications? We should probably ask about when it should be disabled based on checksum behaviors.

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.

2 participants