@@ -12,7 +12,6 @@ import aws.smithy.kotlin.runtime.client.config.HttpChecksumConfigOption
1212import aws.smithy.kotlin.runtime.collections.AttributeKey
1313import aws.smithy.kotlin.runtime.hashing.toHashFunction
1414import aws.smithy.kotlin.runtime.http.HttpBody
15- import aws.smithy.kotlin.runtime.http.readAll
1615import aws.smithy.kotlin.runtime.http.request.HttpRequest
1716import aws.smithy.kotlin.runtime.http.response.HttpResponse
1817import aws.smithy.kotlin.runtime.http.response.copy
@@ -90,31 +89,14 @@ public class FlexibleChecksumsResponseInterceptor<I>(
9089 .removePrefix(" x-amz-checksum-" )
9190 .toHashFunction() ? : throw ClientException (" Could not parse checksum algorithm from header $checksumHeader " )
9291
93- if (context.protocolResponse.body is HttpBody .Bytes ) {
94- logger.debug { " Validating checksum before deserialization from $checksumHeader " }
92+ logger.debug { " Validating checksum during deserialization from $checksumHeader " }
9593
96- // Calculate checksum
97- checksumAlgorithm.update(
98- context.protocolResponse.body.readAll() ? : byteArrayOf(),
99- )
100- val sdkChecksumValue = checksumAlgorithm.digest().encodeBase64String()
101-
102- validateAndThrow(
103- serviceChecksumValue,
104- sdkChecksumValue,
105- )
106-
107- return context.protocolResponse
108- } else {
109- logger.debug { " Validating checksum during deserialization from $checksumHeader " }
110-
111- // Wrap the response body in a hashing body
112- return context.protocolResponse.copy(
113- body = context.protocolResponse.body
114- .toHashingBody(checksumAlgorithm, context.protocolResponse.body.contentLength)
115- .toChecksumValidatingBody(serviceChecksumValue),
116- )
117- }
94+ // Wrap the response body in a hashing body
95+ return context.protocolResponse.copy(
96+ body = context.protocolResponse.body
97+ .toHashingBody(checksumAlgorithm, context.protocolResponse.body.contentLength)
98+ .toChecksumValidatingBody(serviceChecksumValue),
99+ )
118100 }
119101}
120102
0 commit comments