Skip to content

Commit efaf71d

Browse files
committed
fix(core/protocols): construction of x-amz-target header
1 parent 48ae272 commit efaf71d

File tree

11 files changed

+41
-16
lines changed

11 files changed

+41
-16
lines changed

packages/core/src/submodules/protocols/json/AwsJson1_0Protocol.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe(AwsJson1_0Protocol.name, () => {
3030
it("serializes blobs and timestamps", () => {
3131
const protocol = new AwsJson1_0Protocol({
3232
defaultNamespace: "namespace",
33+
serviceTarget: "JsonRpc10",
3334
});
3435
protocol.setSerdeContext(serdeContext);
3536
const codec = protocol.getPayloadCodec();
@@ -55,6 +56,7 @@ describe(AwsJson1_0Protocol.name, () => {
5556
it("deserializes blobs and timestamps", async () => {
5657
const protocol = new AwsJson1_0Protocol({
5758
defaultNamespace: "namespace",
59+
serviceTarget: "JsonRpc10",
5860
});
5961
protocol.setSerdeContext(serdeContext);
6062
const codec = protocol.getPayloadCodec();
@@ -73,6 +75,7 @@ describe(AwsJson1_0Protocol.name, () => {
7375
it("ignores JSON name and HTTP bindings", async () => {
7476
const protocol = new AwsJson1_0Protocol({
7577
defaultNamespace: "namespace",
78+
serviceTarget: "JsonRpc10",
7679
});
7780
protocol.setSerdeContext(serdeContext);
7881

packages/core/src/submodules/protocols/json/AwsJson1_0Protocol.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
2020
return "1.0" as const;
2121
}
2222

23+
/**
24+
* @override
25+
*/
2326
protected getDefaultContentType(): string {
24-
return "application/x-amz-json-1.1";
27+
return "application/x-amz-json-1.0";
2528
}
2629
}

packages/core/src/submodules/protocols/json/AwsJson1_1Protocol.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ import { HttpResponse } from "@smithy/protocol-http";
22
import { describe, expect, test as it } from "vitest";
33

44
import { context, deleteObjects } from "../test-schema.spec";
5-
import { AwsJson1_0Protocol } from "./AwsJson1_0Protocol";
5+
import { AwsJson1_1Protocol } from "./AwsJson1_1Protocol";
66

77
/**
88
* These tests are cursory since most coverage is provided by protocol tests.
99
*/
10-
describe(AwsJson1_0Protocol, () => {
10+
describe(AwsJson1_1Protocol, () => {
1111
it("is 1.0", async () => {
12-
const protocol = new AwsJson1_0Protocol({
12+
const protocol = new AwsJson1_1Protocol({
1313
defaultNamespace: "",
14+
serviceTarget: "JsonRpc11",
1415
});
1516
expect(protocol.getShapeId()).toEqual("aws.protocols#awsJson1_0");
1617
});
1718

1819
it("serializes a request", async () => {
19-
const protocol = new AwsJson1_0Protocol({
20+
const protocol = new AwsJson1_1Protocol({
2021
defaultNamespace: "",
22+
serviceTarget: "JsonRpc11",
2123
});
2224
const httpRequest = await protocol.serializeRequest(
2325
deleteObjects,
@@ -59,8 +61,9 @@ describe(AwsJson1_0Protocol, () => {
5961
headers: {},
6062
});
6163

62-
const protocol = new AwsJson1_0Protocol({
64+
const protocol = new AwsJson1_1Protocol({
6365
defaultNamespace: "",
66+
serviceTarget: "JsonRpc11",
6467
});
6568

6669
const output = await protocol.deserializeResponse(deleteObjects, context, httpResponse);

packages/core/src/submodules/protocols/json/AwsJson1_1Protocol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
2020
return "1.1" as const;
2121
}
2222

23+
/**
24+
* @override
25+
*/
2326
protected getDefaultContentType(): string {
2427
return "application/x-amz-json-1.1";
2528
}

packages/core/src/submodules/protocols/json/AwsJsonRpcProtocol.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe(AwsJsonRpcProtocol.name, () => {
77
it("has expected codec settings", async () => {
88
const protocol = new (class extends AwsJsonRpcProtocol {
99
constructor() {
10-
super({ defaultNamespace: "" });
10+
super({ defaultNamespace: "", serviceTarget: "" });
1111
}
1212

1313
getShapeId(): string {

packages/core/src/submodules/protocols/json/AwsRestJsonProtocol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
158158
throw exception;
159159
}
160160

161+
/**
162+
* @override
163+
*/
161164
protected getDefaultContentType(): string {
162165
return "application/json";
163166
}

packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ export class AwsQueryProtocol extends RpcProtocol {
213213
return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";
214214
}
215215

216+
/**
217+
* @override
218+
*/
216219
protected getDefaultContentType(): string {
217220
return "application/x-www-form-urlencoded";
218221
}

packages/core/src/submodules/protocols/xml/AwsRestXmlProtocol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
173173
throw exception;
174174
}
175175

176+
/**
177+
* @override
178+
*/
176179
protected getDefaultContentType(): string {
177180
return "application/xml";
178181
}

private/aws-protocoltests-json-10-schema/src/runtimeConfig.shared.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export const getRuntimeConfig = (config: JSONRPC10ClientConfig) => {
3131
},
3232
],
3333
logger: config?.logger ?? new NoOpLogger(),
34-
protocol: config?.protocol ?? new AwsJson1_0Protocol({ defaultNamespace: "aws.protocoltests.json10" }),
34+
protocol:
35+
config?.protocol ??
36+
new AwsJson1_0Protocol({ defaultNamespace: "aws.protocoltests.json10", serviceTarget: "JsonRpc10" }),
3537
serviceId: config?.serviceId ?? "JSON RPC 10",
3638
urlParser: config?.urlParser ?? parseUrl,
3739
utf8Decoder: config?.utf8Decoder ?? fromUtf8,

private/aws-protocoltests-json-schema/src/runtimeConfig.shared.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export const getRuntimeConfig = (config: JsonProtocolClientConfig) => {
3131
},
3232
],
3333
logger: config?.logger ?? new NoOpLogger(),
34-
protocol: config?.protocol ?? new AwsJson1_1Protocol({ defaultNamespace: "aws.protocoltests.json" }),
34+
protocol:
35+
config?.protocol ??
36+
new AwsJson1_1Protocol({ defaultNamespace: "aws.protocoltests.json", serviceTarget: "JsonProtocol" }),
3537
serviceId: config?.serviceId ?? "Json Protocol",
3638
urlParser: config?.urlParser ?? parseUrl,
3739
utf8Decoder: config?.utf8Decoder ?? fromUtf8,

0 commit comments

Comments
 (0)