diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/EcsCredentialsProviderTest.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/EcsCredentialsProviderTest.kt index eb2e336a9630..1b68a3ae0fe5 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/EcsCredentialsProviderTest.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/EcsCredentialsProviderTest.kt @@ -9,9 +9,9 @@ import aws.sdk.kotlin.runtime.config.AwsSdkSetting import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException import aws.smithy.kotlin.runtime.http.Headers +import aws.smithy.kotlin.runtime.http.HttpBody import aws.smithy.kotlin.runtime.http.HttpMethod import aws.smithy.kotlin.runtime.http.HttpStatusCode -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.request.HttpRequest import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder import aws.smithy.kotlin.runtime.http.request.header @@ -54,7 +54,7 @@ class EcsCredentialsProviderTest { "Expiration" : "${expectedExpiration.format(TimestampFormat.ISO_8601)}" } """.encodeToByteArray() - return HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(payload)) + return HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(payload)) } private fun errorResponse( @@ -62,7 +62,7 @@ class EcsCredentialsProviderTest { headers: Headers = Headers.Empty, body: String = "", ): HttpResponse = - HttpResponse(statusCode, headers, ByteArrayContent(body.encodeToByteArray())) + HttpResponse(statusCode, headers, HttpBody.fromBytes(body.encodeToByteArray())) private fun ecsRequest(url: String, authToken: String? = null): HttpRequest { val resolvedUrl = Url.parse(url) diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProviderTest.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProviderTest.kt index c701eaa2a5c3..b3eebe13d623 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProviderTest.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProviderTest.kt @@ -14,7 +14,6 @@ import aws.smithy.kotlin.runtime.http.HttpBody import aws.smithy.kotlin.runtime.http.HttpCall import aws.smithy.kotlin.runtime.http.HttpMethod import aws.smithy.kotlin.runtime.http.HttpStatusCode -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineBase import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineConfig import aws.smithy.kotlin.runtime.http.request.HttpRequest @@ -241,7 +240,7 @@ class ImdsCredentialsProviderTest { HttpResponse( HttpStatusCode.NotFound, Headers.Empty, - ByteArrayContent( + HttpBody.fromBytes( """ diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/SsoCredentialsProviderTest.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/SsoCredentialsProviderTest.kt index 142ee0a9a0ee..78e6503f4ab5 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/SsoCredentialsProviderTest.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/SsoCredentialsProviderTest.kt @@ -9,7 +9,6 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials import aws.smithy.kotlin.runtime.http.Headers import aws.smithy.kotlin.runtime.http.HttpBody import aws.smithy.kotlin.runtime.http.HttpStatusCode -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.response.HttpResponse import aws.smithy.kotlin.runtime.httptest.TestConnection import aws.smithy.kotlin.runtime.httptest.buildTestConnection @@ -169,7 +168,7 @@ class SsoCredentialsProviderTest { val engine = buildTestConnection { expect( - HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(serviceResp.encodeToByteArray())), + HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(serviceResp.encodeToByteArray())), ) } diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsAssumeRoleCredentialsProviderTest.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsAssumeRoleCredentialsProviderTest.kt index 0a04754752cc..c7b5d13815d1 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsAssumeRoleCredentialsProviderTest.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsAssumeRoleCredentialsProviderTest.kt @@ -8,8 +8,8 @@ package aws.sdk.kotlin.runtime.auth.credentials import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.model.RegionDisabledException import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException import aws.smithy.kotlin.runtime.http.Headers +import aws.smithy.kotlin.runtime.http.HttpBody import aws.smithy.kotlin.runtime.http.HttpStatusCode -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.response.HttpResponse import aws.smithy.kotlin.runtime.httptest.CallAsserter import aws.smithy.kotlin.runtime.httptest.buildTestConnection @@ -105,7 +105,7 @@ class StsAssumeRoleCredentialsProviderTest { """ val testEngine = buildTestConnection { - expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, ByteArrayContent(errorResponseBody.encodeToByteArray()))) + expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, HttpBody.fromBytes(errorResponseBody.encodeToByteArray()))) } val provider = StsAssumeRoleCredentialsProvider( @@ -132,7 +132,7 @@ class StsAssumeRoleCredentialsProviderTest { """ val testEngine = buildTestConnection { - expect(HttpResponse(HttpStatusCode.Forbidden, Headers.Empty, ByteArrayContent(errorResponseBody.encodeToByteArray()))) + expect(HttpResponse(HttpStatusCode.Forbidden, Headers.Empty, HttpBody.fromBytes(errorResponseBody.encodeToByteArray()))) } val provider = StsAssumeRoleCredentialsProvider( diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsTestUtils.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsTestUtils.kt index 885fabc5cefd..b162306469a8 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsTestUtils.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsTestUtils.kt @@ -10,7 +10,6 @@ import aws.smithy.kotlin.runtime.http.Headers import aws.smithy.kotlin.runtime.http.HttpBody import aws.smithy.kotlin.runtime.http.HttpMethod import aws.smithy.kotlin.runtime.http.HttpStatusCode -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder import aws.smithy.kotlin.runtime.http.request.url import aws.smithy.kotlin.runtime.http.response.HttpResponse @@ -76,6 +75,6 @@ object StsTestUtils { """.trimIndent() - return HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(body.encodeToByteArray())) + return HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(body.encodeToByteArray())) } } diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsWebIdentityCredentialsProviderTest.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsWebIdentityCredentialsProviderTest.kt index 06a1ff12668d..0c6bc2b0728a 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsWebIdentityCredentialsProviderTest.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/StsWebIdentityCredentialsProviderTest.kt @@ -8,8 +8,8 @@ package aws.sdk.kotlin.runtime.auth.credentials import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException import aws.smithy.kotlin.runtime.http.Headers +import aws.smithy.kotlin.runtime.http.HttpBody import aws.smithy.kotlin.runtime.http.HttpStatusCode -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.response.HttpResponse import aws.smithy.kotlin.runtime.httptest.CallAsserter import aws.smithy.kotlin.runtime.httptest.TestConnection @@ -67,7 +67,7 @@ class StsWebIdentityCredentialsProviderTest { """.trimIndent() - return HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(body.encodeToByteArray())) + return HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(body.encodeToByteArray())) } @Test @@ -160,7 +160,7 @@ class StsWebIdentityCredentialsProviderTest { """ val testEngine = buildTestConnection { - expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, ByteArrayContent(errorResponseBody.encodeToByteArray()))) + expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, HttpBody.fromBytes(errorResponseBody.encodeToByteArray()))) } val testPlatform = TestPlatformProvider( diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsTestUtils.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsTestUtils.kt index 5859ce0079be..af7263fc9606 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsTestUtils.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsTestUtils.kt @@ -6,9 +6,9 @@ package aws.sdk.kotlin.runtime.config.imds import aws.smithy.kotlin.runtime.http.Headers +import aws.smithy.kotlin.runtime.http.HttpBody import aws.smithy.kotlin.runtime.http.HttpMethod import aws.smithy.kotlin.runtime.http.HttpStatusCode -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.request.HttpRequest import aws.smithy.kotlin.runtime.http.request.url import aws.smithy.kotlin.runtime.http.response.HttpResponse @@ -27,7 +27,7 @@ fun tokenResponse(ttl: Int, token: String): HttpResponse = HttpResponse( Headers { append(X_AWS_EC2_METADATA_TOKEN_TTL_SECONDS, ttl.toString()) }, - ByteArrayContent(token.encodeToByteArray()), + HttpBody.fromBytes(token.encodeToByteArray()), ) fun imdsRequest(url: String, token: String): HttpRequest = HttpRequest { @@ -39,5 +39,5 @@ fun imdsRequest(url: String, token: String): HttpRequest = HttpRequest { fun imdsResponse(body: String): HttpResponse = HttpResponse( HttpStatusCode.OK, Headers.Empty, - ByteArrayContent(body.encodeToByteArray()), + HttpBody.fromBytes(body.encodeToByteArray()), ) diff --git a/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/RestJson1.kt b/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/RestJson1.kt index 07c94a942fe2..b00d159678be 100644 --- a/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/RestJson1.kt +++ b/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/RestJson1.kt @@ -55,8 +55,7 @@ class RestJson1 : JsonHttpBindingProtocolGenerator() { val target = ctx.model.expectShape(httpPayload.member.target) writer.withBlock("if (input.#L == null) {", "}", memberName) { if (target is StructureShape) { - addImport(RuntimeTypes.Http.ByteArrayContent) - write("builder.body = #T(#S.encodeToByteArray())", RuntimeTypes.Http.ByteArrayContent, "{}") + write("builder.body = #T.fromBytes(#S.encodeToByteArray())", RuntimeTypes.Http.HttpBody, "{}") } // Content-Type still needs to be set for non-structured payloads // https://github.com/awslabs/smithy/blob/main/smithy-aws-protocol-tests/model/restJson1/http-content-type.smithy#L174 diff --git a/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/core/QueryHttpBindingProtocolGenerator.kt b/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/core/QueryHttpBindingProtocolGenerator.kt index 075fe1347d23..7afec2376221 100644 --- a/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/core/QueryHttpBindingProtocolGenerator.kt +++ b/codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/core/QueryHttpBindingProtocolGenerator.kt @@ -56,7 +56,7 @@ abstract class QueryHttpBindingProtocolGenerator : AwsHttpBindingProtocolGenerat val service = ctx.model.expectShape(ctx.settings.service) val version = service.version writer.write("""val content = "Action=$action&Version=$version"""") - writer.write("builder.body = #T(content.encodeToByteArray())", RuntimeTypes.Http.ByteArrayContent) + writer.write("builder.body = #T.fromBytes(content.encodeToByteArray())", RuntimeTypes.Http.HttpBody) } else { super.renderSerializeHttpBody(ctx, op, writer) } diff --git a/services/glacier/common/test/aws/sdk/kotlin/services/glacier/internal/TreeHasherTest.kt b/services/glacier/common/test/aws/sdk/kotlin/services/glacier/internal/TreeHasherTest.kt index d127ab23451e..21ddb3bf62fc 100644 --- a/services/glacier/common/test/aws/sdk/kotlin/services/glacier/internal/TreeHasherTest.kt +++ b/services/glacier/common/test/aws/sdk/kotlin/services/glacier/internal/TreeHasherTest.kt @@ -8,7 +8,6 @@ package aws.sdk.kotlin.services.glacier.internal import aws.smithy.kotlin.runtime.content.ByteStream import aws.smithy.kotlin.runtime.hashing.HashFunction import aws.smithy.kotlin.runtime.hashing.Sha256 -import aws.smithy.kotlin.runtime.http.content.ByteArrayContent import aws.smithy.kotlin.runtime.http.toHttpBody import aws.smithy.kotlin.runtime.io.SdkBuffer import aws.smithy.kotlin.runtime.io.SdkByteChannel @@ -37,7 +36,7 @@ class TreeHasherTest { val chunkSize = 3 val hasher = TreeHasherImpl(chunkSize) { RollingSumHashFunction(chunkSize) } - val body = ByteArrayContent(payload) + val body = HttpBody.fromBytes(payload) val hashes = hasher.calculateHashes(body) assertContentEquals(fullHash, hashes.fullHash)