Skip to content

Commit a6d4ba6

Browse files
committed
fix(clients): lowercase all header names in serializer
The HTTP request class doesn't have any implementations to insure case-insensitivity of the http headers. So we need to be mindful when populating these headers. Otherwise, the reqeust signature will be messed up. This change will ensure the protocol-specific default headers like content-type will be overriden by the serialized header if exists. For other headers added through middleware stack either by customization or users, it wouldn't affect signing or sending as long as the request doesn't contain same header names in different casing. All the internal headers will be consistent. But users should be careful when they are adding their own headers. We don't add middleware to lowercase all headers to prevent alternating the users' customizations. Ref: #1800
1 parent d4c302b commit a6d4ba6

File tree

19 files changed

+255
-255
lines changed

19 files changed

+255
-255
lines changed

clients/client-api-gateway/protocols/Aws_restJson1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ export const serializeAws_restJson1GetExportCommand = async (
23092309
): Promise<__HttpRequest> => {
23102310
const headers: any = {
23112311
"content-type": "application/json",
2312-
...(isSerializableHeaderValue(input.accepts) && { Accept: input.accepts! }),
2312+
...(isSerializableHeaderValue(input.accepts) && { accept: input.accepts! }),
23132313
};
23142314
let resolvedPath = "/restapis/{restApiId}/stages/{stageName}/exports/{exportType}";
23152315
if (input.restApiId !== undefined) {

clients/client-appconfig/protocols/Aws_restJson1.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ export const serializeAws_restJson1CreateHostedConfigurationVersionCommand = asy
251251
): Promise<__HttpRequest> => {
252252
const headers: any = {
253253
"content-type": "application/octet-stream",
254-
...(isSerializableHeaderValue(input.Description) && { Description: input.Description! }),
255-
...(isSerializableHeaderValue(input.ContentType) && { "Content-Type": input.ContentType! }),
254+
...(isSerializableHeaderValue(input.Description) && { description: input.Description! }),
255+
...(isSerializableHeaderValue(input.ContentType) && { "content-type": input.ContentType! }),
256256
...(isSerializableHeaderValue(input.LatestVersionNumber) && {
257-
"Latest-Version-Number": input.LatestVersionNumber!.toString(),
257+
"latest-version-number": input.LatestVersionNumber!.toString(),
258258
}),
259259
};
260260
let resolvedPath =

clients/client-cloudfront/protocols/Aws_restXml.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ export const serializeAws_restXmlDeleteCachePolicyCommand = async (
912912
context: __SerdeContext
913913
): Promise<__HttpRequest> => {
914914
const headers: any = {
915-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
915+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
916916
};
917917
let resolvedPath = "/2020-05-31/cache-policy/{Id}";
918918
if (input.Id !== undefined) {
@@ -942,7 +942,7 @@ export const serializeAws_restXmlDeleteCloudFrontOriginAccessIdentityCommand = a
942942
context: __SerdeContext
943943
): Promise<__HttpRequest> => {
944944
const headers: any = {
945-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
945+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
946946
};
947947
let resolvedPath = "/2020-05-31/origin-access-identity/cloudfront/{Id}";
948948
if (input.Id !== undefined) {
@@ -972,7 +972,7 @@ export const serializeAws_restXmlDeleteDistributionCommand = async (
972972
context: __SerdeContext
973973
): Promise<__HttpRequest> => {
974974
const headers: any = {
975-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
975+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
976976
};
977977
let resolvedPath = "/2020-05-31/distribution/{Id}";
978978
if (input.Id !== undefined) {
@@ -1002,7 +1002,7 @@ export const serializeAws_restXmlDeleteFieldLevelEncryptionConfigCommand = async
10021002
context: __SerdeContext
10031003
): Promise<__HttpRequest> => {
10041004
const headers: any = {
1005-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
1005+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
10061006
};
10071007
let resolvedPath = "/2020-05-31/field-level-encryption/{Id}";
10081008
if (input.Id !== undefined) {
@@ -1032,7 +1032,7 @@ export const serializeAws_restXmlDeleteFieldLevelEncryptionProfileCommand = asyn
10321032
context: __SerdeContext
10331033
): Promise<__HttpRequest> => {
10341034
const headers: any = {
1035-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
1035+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
10361036
};
10371037
let resolvedPath = "/2020-05-31/field-level-encryption-profile/{Id}";
10381038
if (input.Id !== undefined) {
@@ -1062,7 +1062,7 @@ export const serializeAws_restXmlDeleteKeyGroupCommand = async (
10621062
context: __SerdeContext
10631063
): Promise<__HttpRequest> => {
10641064
const headers: any = {
1065-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
1065+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
10661066
};
10671067
let resolvedPath = "/2020-05-31/key-group/{Id}";
10681068
if (input.Id !== undefined) {
@@ -1120,7 +1120,7 @@ export const serializeAws_restXmlDeleteOriginRequestPolicyCommand = async (
11201120
context: __SerdeContext
11211121
): Promise<__HttpRequest> => {
11221122
const headers: any = {
1123-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
1123+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
11241124
};
11251125
let resolvedPath = "/2020-05-31/origin-request-policy/{Id}";
11261126
if (input.Id !== undefined) {
@@ -1150,7 +1150,7 @@ export const serializeAws_restXmlDeletePublicKeyCommand = async (
11501150
context: __SerdeContext
11511151
): Promise<__HttpRequest> => {
11521152
const headers: any = {
1153-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
1153+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
11541154
};
11551155
let resolvedPath = "/2020-05-31/public-key/{Id}";
11561156
if (input.Id !== undefined) {
@@ -1213,7 +1213,7 @@ export const serializeAws_restXmlDeleteStreamingDistributionCommand = async (
12131213
context: __SerdeContext
12141214
): Promise<__HttpRequest> => {
12151215
const headers: any = {
1216-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
1216+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
12171217
};
12181218
let resolvedPath = "/2020-05-31/streaming-distribution/{Id}";
12191219
if (input.Id !== undefined) {
@@ -2387,7 +2387,7 @@ export const serializeAws_restXmlUpdateCachePolicyCommand = async (
23872387
): Promise<__HttpRequest> => {
23882388
const headers: any = {
23892389
"content-type": "application/xml",
2390-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2390+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
23912391
};
23922392
let resolvedPath = "/2020-05-31/cache-policy/{Id}";
23932393
if (input.Id !== undefined) {
@@ -2425,7 +2425,7 @@ export const serializeAws_restXmlUpdateCloudFrontOriginAccessIdentityCommand = a
24252425
): Promise<__HttpRequest> => {
24262426
const headers: any = {
24272427
"content-type": "application/xml",
2428-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2428+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
24292429
};
24302430
let resolvedPath = "/2020-05-31/origin-access-identity/cloudfront/{Id}/config";
24312431
if (input.Id !== undefined) {
@@ -2466,7 +2466,7 @@ export const serializeAws_restXmlUpdateDistributionCommand = async (
24662466
): Promise<__HttpRequest> => {
24672467
const headers: any = {
24682468
"content-type": "application/xml",
2469-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2469+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
24702470
};
24712471
let resolvedPath = "/2020-05-31/distribution/{Id}/config";
24722472
if (input.Id !== undefined) {
@@ -2504,7 +2504,7 @@ export const serializeAws_restXmlUpdateFieldLevelEncryptionConfigCommand = async
25042504
): Promise<__HttpRequest> => {
25052505
const headers: any = {
25062506
"content-type": "application/xml",
2507-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2507+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
25082508
};
25092509
let resolvedPath = "/2020-05-31/field-level-encryption/{Id}/config";
25102510
if (input.Id !== undefined) {
@@ -2542,7 +2542,7 @@ export const serializeAws_restXmlUpdateFieldLevelEncryptionProfileCommand = asyn
25422542
): Promise<__HttpRequest> => {
25432543
const headers: any = {
25442544
"content-type": "application/xml",
2545-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2545+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
25462546
};
25472547
let resolvedPath = "/2020-05-31/field-level-encryption-profile/{Id}/config";
25482548
if (input.Id !== undefined) {
@@ -2580,7 +2580,7 @@ export const serializeAws_restXmlUpdateKeyGroupCommand = async (
25802580
): Promise<__HttpRequest> => {
25812581
const headers: any = {
25822582
"content-type": "application/xml",
2583-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2583+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
25842584
};
25852585
let resolvedPath = "/2020-05-31/key-group/{Id}";
25862586
if (input.Id !== undefined) {
@@ -2618,7 +2618,7 @@ export const serializeAws_restXmlUpdateOriginRequestPolicyCommand = async (
26182618
): Promise<__HttpRequest> => {
26192619
const headers: any = {
26202620
"content-type": "application/xml",
2621-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2621+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
26222622
};
26232623
let resolvedPath = "/2020-05-31/origin-request-policy/{Id}";
26242624
if (input.Id !== undefined) {
@@ -2656,7 +2656,7 @@ export const serializeAws_restXmlUpdatePublicKeyCommand = async (
26562656
): Promise<__HttpRequest> => {
26572657
const headers: any = {
26582658
"content-type": "application/xml",
2659-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2659+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
26602660
};
26612661
let resolvedPath = "/2020-05-31/public-key/{Id}/config";
26622662
if (input.Id !== undefined) {
@@ -2747,7 +2747,7 @@ export const serializeAws_restXmlUpdateStreamingDistributionCommand = async (
27472747
): Promise<__HttpRequest> => {
27482748
const headers: any = {
27492749
"content-type": "application/xml",
2750-
...(isSerializableHeaderValue(input.IfMatch) && { "If-Match": input.IfMatch! }),
2750+
...(isSerializableHeaderValue(input.IfMatch) && { "if-match": input.IfMatch! }),
27512751
};
27522752
let resolvedPath = "/2020-05-31/streaming-distribution/{Id}/config";
27532753
if (input.Id !== undefined) {

clients/client-cloudsearch-domain/protocols/Aws_restJson1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const serializeAws_restJson1UploadDocumentsCommand = async (
9898
): Promise<__HttpRequest> => {
9999
const headers: any = {
100100
"content-type": "application/octet-stream",
101-
...(isSerializableHeaderValue(input.contentType) && { "Content-Type": input.contentType! }),
101+
...(isSerializableHeaderValue(input.contentType) && { "content-type": input.contentType! }),
102102
};
103103
let resolvedPath = "/2013-01-01/documents/batch";
104104
const query: any = {

clients/client-codeguruprofiler/protocols/Aws_restJson1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ export const serializeAws_restJson1GetProfileCommand = async (
368368
context: __SerdeContext
369369
): Promise<__HttpRequest> => {
370370
const headers: any = {
371-
...(isSerializableHeaderValue(input.accept) && { Accept: input.accept! }),
371+
...(isSerializableHeaderValue(input.accept) && { accept: input.accept! }),
372372
};
373373
let resolvedPath = "/profilingGroups/{profilingGroupName}/profile";
374374
if (input.profilingGroupName !== undefined) {
@@ -443,7 +443,7 @@ export const serializeAws_restJson1PostAgentProfileCommand = async (
443443
): Promise<__HttpRequest> => {
444444
const headers: any = {
445445
"content-type": "application/octet-stream",
446-
...(isSerializableHeaderValue(input.contentType) && { "Content-Type": input.contentType! }),
446+
...(isSerializableHeaderValue(input.contentType) && { "content-type": input.contentType! }),
447447
};
448448
let resolvedPath = "/profilingGroups/{profilingGroupName}/agentProfile";
449449
if (input.profilingGroupName !== undefined) {

clients/client-cognito-sync/protocols/Aws_restJson1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ export const serializeAws_restJson1UpdateRecordsCommand = async (
692692
): Promise<__HttpRequest> => {
693693
const headers: any = {
694694
"content-type": "application/json",
695-
...(isSerializableHeaderValue(input.ClientContext) && { "x-amz-Client-Context": input.ClientContext! }),
695+
...(isSerializableHeaderValue(input.ClientContext) && { "x-amz-client-context": input.ClientContext! }),
696696
};
697697
let resolvedPath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets/{DatasetName}";
698698
if (input.IdentityPoolId !== undefined) {

clients/client-connectparticipant/protocols/Aws_restJson1.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const serializeAws_restJson1CreateParticipantConnectionCommand = async (
3636
): Promise<__HttpRequest> => {
3737
const headers: any = {
3838
"content-type": "application/json",
39-
...(isSerializableHeaderValue(input.ParticipantToken) && { "X-Amz-Bearer": input.ParticipantToken! }),
39+
...(isSerializableHeaderValue(input.ParticipantToken) && { "x-amz-bearer": input.ParticipantToken! }),
4040
};
4141
let resolvedPath = "/participant/connection";
4242
let body: any;
@@ -62,7 +62,7 @@ export const serializeAws_restJson1DisconnectParticipantCommand = async (
6262
): Promise<__HttpRequest> => {
6363
const headers: any = {
6464
"content-type": "application/json",
65-
...(isSerializableHeaderValue(input.ConnectionToken) && { "X-Amz-Bearer": input.ConnectionToken! }),
65+
...(isSerializableHeaderValue(input.ConnectionToken) && { "x-amz-bearer": input.ConnectionToken! }),
6666
};
6767
let resolvedPath = "/participant/disconnect";
6868
let body: any;
@@ -87,7 +87,7 @@ export const serializeAws_restJson1GetTranscriptCommand = async (
8787
): Promise<__HttpRequest> => {
8888
const headers: any = {
8989
"content-type": "application/json",
90-
...(isSerializableHeaderValue(input.ConnectionToken) && { "X-Amz-Bearer": input.ConnectionToken! }),
90+
...(isSerializableHeaderValue(input.ConnectionToken) && { "x-amz-bearer": input.ConnectionToken! }),
9191
};
9292
let resolvedPath = "/participant/transcript";
9393
let body: any;
@@ -120,7 +120,7 @@ export const serializeAws_restJson1SendEventCommand = async (
120120
): Promise<__HttpRequest> => {
121121
const headers: any = {
122122
"content-type": "application/json",
123-
...(isSerializableHeaderValue(input.ConnectionToken) && { "X-Amz-Bearer": input.ConnectionToken! }),
123+
...(isSerializableHeaderValue(input.ConnectionToken) && { "x-amz-bearer": input.ConnectionToken! }),
124124
};
125125
let resolvedPath = "/participant/event";
126126
let body: any;
@@ -147,7 +147,7 @@ export const serializeAws_restJson1SendMessageCommand = async (
147147
): Promise<__HttpRequest> => {
148148
const headers: any = {
149149
"content-type": "application/json",
150-
...(isSerializableHeaderValue(input.ConnectionToken) && { "X-Amz-Bearer": input.ConnectionToken! }),
150+
...(isSerializableHeaderValue(input.ConnectionToken) && { "x-amz-bearer": input.ConnectionToken! }),
151151
};
152152
let resolvedPath = "/participant/message";
153153
let body: any;

clients/client-ebs/protocols/Aws_restJson1.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export const serializeAws_restJson1CompleteSnapshotCommand = async (
3636
): Promise<__HttpRequest> => {
3737
const headers: any = {
3838
...(isSerializableHeaderValue(input.ChangedBlocksCount) && {
39-
"x-amz-ChangedBlocksCount": input.ChangedBlocksCount!.toString(),
39+
"x-amz-changedblockscount": input.ChangedBlocksCount!.toString(),
4040
}),
41-
...(isSerializableHeaderValue(input.Checksum) && { "x-amz-Checksum": input.Checksum! }),
42-
...(isSerializableHeaderValue(input.ChecksumAlgorithm) && { "x-amz-Checksum-Algorithm": input.ChecksumAlgorithm! }),
41+
...(isSerializableHeaderValue(input.Checksum) && { "x-amz-checksum": input.Checksum! }),
42+
...(isSerializableHeaderValue(input.ChecksumAlgorithm) && { "x-amz-checksum-algorithm": input.ChecksumAlgorithm! }),
4343
...(isSerializableHeaderValue(input.ChecksumAggregationMethod) && {
44-
"x-amz-Checksum-Aggregation-Method": input.ChecksumAggregationMethod!,
44+
"x-amz-checksum-aggregation-method": input.ChecksumAggregationMethod!,
4545
}),
4646
};
4747
let resolvedPath = "/snapshots/completion/{SnapshotId}";
@@ -184,10 +184,10 @@ export const serializeAws_restJson1PutSnapshotBlockCommand = async (
184184
const headers: any = {
185185
"content-type": "application/octet-stream",
186186
"x-amz-content-sha256": "UNSIGNED-PAYLOAD",
187-
...(isSerializableHeaderValue(input.DataLength) && { "x-amz-Data-Length": input.DataLength!.toString() }),
188-
...(isSerializableHeaderValue(input.Progress) && { "x-amz-Progress": input.Progress!.toString() }),
189-
...(isSerializableHeaderValue(input.Checksum) && { "x-amz-Checksum": input.Checksum! }),
190-
...(isSerializableHeaderValue(input.ChecksumAlgorithm) && { "x-amz-Checksum-Algorithm": input.ChecksumAlgorithm! }),
187+
...(isSerializableHeaderValue(input.DataLength) && { "x-amz-data-length": input.DataLength!.toString() }),
188+
...(isSerializableHeaderValue(input.Progress) && { "x-amz-progress": input.Progress!.toString() }),
189+
...(isSerializableHeaderValue(input.Checksum) && { "x-amz-checksum": input.Checksum! }),
190+
...(isSerializableHeaderValue(input.ChecksumAlgorithm) && { "x-amz-checksum-algorithm": input.ChecksumAlgorithm! }),
191191
};
192192
let resolvedPath = "/snapshots/{SnapshotId}/blocks/{BlockIndex}";
193193
if (input.SnapshotId !== undefined) {

clients/client-glacier/protocols/Aws_restJson1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ export const serializeAws_restJson1GetJobOutputCommand = async (
658658
context: __SerdeContext
659659
): Promise<__HttpRequest> => {
660660
const headers: any = {
661-
...(isSerializableHeaderValue(input.range) && { Range: input.range! }),
661+
...(isSerializableHeaderValue(input.range) && { range: input.range! }),
662662
};
663663
let resolvedPath = "/{accountId}/vaults/{vaultName}/jobs/{jobId}/output";
664664
if (input.accountId !== undefined) {
@@ -1435,7 +1435,7 @@ export const serializeAws_restJson1UploadMultipartPartCommand = async (
14351435
const headers: any = {
14361436
"content-type": "application/octet-stream",
14371437
...(isSerializableHeaderValue(input.checksum) && { "x-amz-sha256-tree-hash": input.checksum! }),
1438-
...(isSerializableHeaderValue(input.range) && { "Content-Range": input.range! }),
1438+
...(isSerializableHeaderValue(input.range) && { "content-range": input.range! }),
14391439
};
14401440
let resolvedPath = "/{accountId}/vaults/{vaultName}/multipart-uploads/{uploadId}";
14411441
if (input.accountId !== undefined) {

0 commit comments

Comments
 (0)