@@ -31,8 +31,19 @@ class AwsChunkedContentEncodingDecorator : ClientCodegenDecorator {
3131 // This decorator must decorate after any of the following:
3232 // - HttpRequestChecksumDecorator
3333 // - HttpRequestCompressionDecorator
34+ //
35+ // TODO(https://github.com/smithy-lang/smithy-rs/issues/4382): Change ORDER to -1 once
36+ // a dedicated Smithy trait is available.
37+ // Why ORDER -2 is needed temporarily:
38+ // - AwsChunkedContentEncodingDecorator is part of AwsSdkCodegenDecorator (ORDER -1),
39+ // which only applies to S3
40+ // - HttpChecksumTest needs aws-chunked for flexible checksums but uses a non-S3 model
41+ // - To test this, AwsChunkedContentEncodingDecorator must be passed separately to
42+ // awsSdkIntegrationTest alongside AwsSdkCodegenDecorator
43+ // - Since HttpRequestChecksumDecorator is in AwsSdkCodegenDecorator (ORDER -1),
44+ // we need ORDER -2 to run before it
3445 override val order: Byte =
35- (minOf(HttpRequestChecksumDecorator .ORDER , HttpRequestCompressionDecorator .ORDER ) - 1 ).toByte()
46+ (minOf(HttpRequestChecksumDecorator .ORDER , HttpRequestCompressionDecorator .ORDER ) - 2 ).toByte()
3647
3748 override fun configCustomizations (
3849 codegenContext : ClientCodegenContext ,
@@ -46,38 +57,16 @@ class AwsChunkedContentEncodingDecorator : ClientCodegenDecorator {
4657 ) = baseCustomizations + AwsChunkedOperationCustomization (codegenContext, operation)
4758}
4859
49- // TODO(https://github.com/smithy-lang/smithy-rs/issues/4382): Replace this heuristic with a dedicated
50- // Smithy trait once available to determine whether operations require aws-chunked encoding.
51- private fun operationRequiresAwsChunked (
52- codegenContext : ClientCodegenContext ,
53- operation : OperationShape ,
54- ): Boolean {
55- val checksumTrait = operation.getTrait<HttpChecksumTrait >() ? : return false
56- val requestAlgorithmMember =
57- checksumTrait.requestAlgorithmMemberShape(codegenContext, operation) ? : return false
58- requestAlgorithmMember.getTrait<HttpHeaderTrait >()?.value ? : return false
59- val input = codegenContext.model.expectShape(operation.inputShape, StructureShape ::class .java)
60- return input.hasStreamingMember(codegenContext.model)
61- }
62-
63- private fun serviceRequiresAwsChunked (codegenContext : ClientCodegenContext ): Boolean =
64- codegenContext.serviceShape.allOperations.any { operationId ->
65- val operation = codegenContext.model.expectShape(operationId, OperationShape ::class .java)
66- operationRequiresAwsChunked(codegenContext, operation)
67- }
68-
6960private class AwsChunkedConfigCustomization (
7061 codegenContext : ClientCodegenContext ,
7162) : ConfigCustomization() {
7263 private val runtimeConfig = codegenContext.runtimeConfig
7364 private val moduleUseName = codegenContext.moduleUseName()
74- private val serviceRequiresChunking = serviceRequiresAwsChunked(codegenContext)
7565
7666 override fun section (section : ServiceConfig ) =
7767 writable {
7868 when (section) {
7969 ServiceConfig .BuilderImpl -> {
80- if (! serviceRequiresChunking) return @writable
8170 rustTemplate(
8271 """
8372 /// Sets the chunk size for [`aws-chunked encoding`].
@@ -144,6 +133,20 @@ private class AwsChunkedConfigCustomization(
144133 }
145134}
146135
136+ // TODO(https://github.com/smithy-lang/smithy-rs/issues/4382): Replace this condition with a dedicated
137+ // Smithy trait once available to determine whether operations require aws-chunked encoding.
138+ private fun operationRequiresAwsChunked (
139+ codegenContext : ClientCodegenContext ,
140+ operation : OperationShape ,
141+ ): Boolean {
142+ val checksumTrait = operation.getTrait<HttpChecksumTrait >() ? : return false
143+ val requestAlgorithmMember =
144+ checksumTrait.requestAlgorithmMemberShape(codegenContext, operation) ? : return false
145+ requestAlgorithmMember.getTrait<HttpHeaderTrait >()?.value ? : return false
146+ val input = codegenContext.model.expectShape(operation.inputShape, StructureShape ::class .java)
147+ return input.hasStreamingMember(codegenContext.model)
148+ }
149+
147150private class AwsChunkedOperationCustomization (
148151 private val codegenContext : ClientCodegenContext ,
149152 private val operation : OperationShape ,
0 commit comments