Skip to content

Commit 08b4a37

Browse files
committed
Drop support for http body dot bytes response checksums
1 parent e2068e7 commit 08b4a37

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

codegen/protocol-tests/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ data class ProtocolTest(val projectionName: String, val serviceShapeId: String,
2525
val enabledProtocols = listOf(
2626
ProtocolTest("aws-ec2-query", "aws.protocoltests.ec2#AwsEc2"),
2727

28-
// FIXME: Re-enable. These test are broken after an update: https://github.com/smithy-lang/smithy/pull/2467
28+
// FIXME: Re-enable. This test is broken after a smithy update: https://github.com/smithy-lang/smithy/pull/2467
2929
// ProtocolTest("aws-json-10", "aws.protocoltests.json10#JsonRpc10"),
3030

3131
ProtocolTest("aws-json-11", "aws.protocoltests.json#JsonProtocol"),
3232

33-
// FIXME: Re-enable. These test are broken after an update: https://github.com/smithy-lang/smithy/pull/2403
34-
// ProtocolTest("aws-restjson", "aws.protocoltests.restjson#RestJson"),
35-
// ProtocolTest("aws-restxml", "aws.protocoltests.restxml#RestXml"),
33+
// FIXME: Re-enable. These tests are broken after a smithy update: https://github.com/smithy-lang/smithy/pull/2403
34+
// ProtocolTest("aws-restjson", "aws.protocoltests.restjson#RestJson"),
35+
// ProtocolTest("aws-restxml", "aws.protocoltests.restxml#RestXml"),
3636

3737
ProtocolTest("aws-restxml-xmlns", "aws.protocoltests.restxml.xmlns#RestXmlWithNamespace"),
3838
ProtocolTest("aws-query", "aws.protocoltests.query#AwsQuery"),
3939

40-
// FIXME: Re-enable. These test are broken after an update: https://github.com/smithy-lang/smithy/pull/2467
40+
// FIXME: Re-enable. This test is broken after a smithy update: https://github.com/smithy-lang/smithy/pull/2467
4141
// ProtocolTest("smithy-rpcv2-cbor", "smithy.protocoltests.rpcv2Cbor#RpcV2Protocol"),
4242

4343
// Custom hand written tests

runtime/protocol/http-client/common/src/aws/smithy/kotlin/runtime/http/interceptors/FlexibleChecksumsResponseInterceptor.kt

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import aws.smithy.kotlin.runtime.client.config.HttpChecksumConfigOption
1212
import aws.smithy.kotlin.runtime.collections.AttributeKey
1313
import aws.smithy.kotlin.runtime.hashing.toHashFunction
1414
import aws.smithy.kotlin.runtime.http.HttpBody
15-
import aws.smithy.kotlin.runtime.http.readAll
1615
import aws.smithy.kotlin.runtime.http.request.HttpRequest
1716
import aws.smithy.kotlin.runtime.http.response.HttpResponse
1817
import 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

Comments
 (0)