Skip to content

Commit 91355d1

Browse files
committed
Fix HttpChecksumRequiredTrait
1 parent 08b4a37 commit 91355d1

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/protocol/HttpProtocolClientGenerator.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
package software.amazon.smithy.kotlin.codegen.rendering.protocol
66

7-
import software.amazon.smithy.aws.traits.HttpChecksumTrait
87
import software.amazon.smithy.codegen.core.Symbol
98
import software.amazon.smithy.kotlin.codegen.core.*
109
import software.amazon.smithy.kotlin.codegen.integration.SectionId
@@ -338,21 +337,14 @@ open class HttpProtocolClientGenerator(
338337

339338
/**
340339
* Render optionally installing Md5ChecksumMiddleware.
341-
* The Md5 middleware will only be installed if the operation requires a checksum and the user has not opted-in to flexible checksums.
340+
* The Md5 middleware will only be installed if the operation requires a checksum.
342341
*/
343342
private fun OperationShape.renderIsMd5ChecksumRequired(writer: KotlinWriter) {
344-
val httpChecksumTrait = getTrait<HttpChecksumTrait>()
345-
346-
// the checksum requirement can be modeled in either HttpChecksumTrait's `requestChecksumRequired` or the HttpChecksumRequired trait
347-
if (!hasTrait<HttpChecksumRequiredTrait>() && httpChecksumTrait == null) {
348-
return
349-
}
350-
351-
if (hasTrait<HttpChecksumRequiredTrait>() || httpChecksumTrait?.isRequestChecksumRequired == true) {
343+
if (hasTrait<HttpChecksumRequiredTrait>()) {
352344
val interceptorSymbol = RuntimeTypes.HttpClient.Interceptors.Md5ChecksumInterceptor
353345
val inputSymbol = ctx.symbolProvider.toSymbol(ctx.model.expectShape(inputShape))
354346
writer.withBlock("op.interceptors.add(#T<#T> {", "})", interceptorSymbol, inputSymbol) {
355-
writer.write("op.context.getOrNull(#T.ChecksumAlgorithm) == null", RuntimeTypes.HttpClient.Operation.HttpOperationContext)
347+
writer.write("true", RuntimeTypes.HttpClient.Operation.HttpOperationContext)
356348
}
357349
}
358350
}

0 commit comments

Comments
 (0)