Skip to content

Commit

Permalink
fix(clients): lowercase all header names in serializer (#1892)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AllanZhengYP authored Jan 13, 2021
1 parent 7a3e8f4 commit 1308721
Show file tree
Hide file tree
Showing 139 changed files with 4,534 additions and 4,519 deletions.
46 changes: 23 additions & 23 deletions clients/client-acm-pca/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const serializeAws_json1_1CreateCertificateAuthorityCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.CreateCertificateAuthority",
"x-amz-target": "ACMPrivateCA.CreateCertificateAuthority",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1CreateCertificateAuthorityRequest(input, context));
Expand All @@ -154,7 +154,7 @@ export const serializeAws_json1_1CreateCertificateAuthorityAuditReportCommand =
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.CreateCertificateAuthorityAuditReport",
"x-amz-target": "ACMPrivateCA.CreateCertificateAuthorityAuditReport",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1CreateCertificateAuthorityAuditReportRequest(input, context));
Expand All @@ -167,7 +167,7 @@ export const serializeAws_json1_1CreatePermissionCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.CreatePermission",
"x-amz-target": "ACMPrivateCA.CreatePermission",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1CreatePermissionRequest(input, context));
Expand All @@ -180,7 +180,7 @@ export const serializeAws_json1_1DeleteCertificateAuthorityCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.DeleteCertificateAuthority",
"x-amz-target": "ACMPrivateCA.DeleteCertificateAuthority",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1DeleteCertificateAuthorityRequest(input, context));
Expand All @@ -193,7 +193,7 @@ export const serializeAws_json1_1DeletePermissionCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.DeletePermission",
"x-amz-target": "ACMPrivateCA.DeletePermission",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1DeletePermissionRequest(input, context));
Expand All @@ -206,7 +206,7 @@ export const serializeAws_json1_1DeletePolicyCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.DeletePolicy",
"x-amz-target": "ACMPrivateCA.DeletePolicy",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1DeletePolicyRequest(input, context));
Expand All @@ -219,7 +219,7 @@ export const serializeAws_json1_1DescribeCertificateAuthorityCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.DescribeCertificateAuthority",
"x-amz-target": "ACMPrivateCA.DescribeCertificateAuthority",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1DescribeCertificateAuthorityRequest(input, context));
Expand All @@ -232,7 +232,7 @@ export const serializeAws_json1_1DescribeCertificateAuthorityAuditReportCommand
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.DescribeCertificateAuthorityAuditReport",
"x-amz-target": "ACMPrivateCA.DescribeCertificateAuthorityAuditReport",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1DescribeCertificateAuthorityAuditReportRequest(input, context));
Expand All @@ -245,7 +245,7 @@ export const serializeAws_json1_1GetCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.GetCertificate",
"x-amz-target": "ACMPrivateCA.GetCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1GetCertificateRequest(input, context));
Expand All @@ -258,7 +258,7 @@ export const serializeAws_json1_1GetCertificateAuthorityCertificateCommand = asy
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.GetCertificateAuthorityCertificate",
"x-amz-target": "ACMPrivateCA.GetCertificateAuthorityCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1GetCertificateAuthorityCertificateRequest(input, context));
Expand All @@ -271,7 +271,7 @@ export const serializeAws_json1_1GetCertificateAuthorityCsrCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.GetCertificateAuthorityCsr",
"x-amz-target": "ACMPrivateCA.GetCertificateAuthorityCsr",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1GetCertificateAuthorityCsrRequest(input, context));
Expand All @@ -284,7 +284,7 @@ export const serializeAws_json1_1GetPolicyCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.GetPolicy",
"x-amz-target": "ACMPrivateCA.GetPolicy",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1GetPolicyRequest(input, context));
Expand All @@ -297,7 +297,7 @@ export const serializeAws_json1_1ImportCertificateAuthorityCertificateCommand =
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.ImportCertificateAuthorityCertificate",
"x-amz-target": "ACMPrivateCA.ImportCertificateAuthorityCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ImportCertificateAuthorityCertificateRequest(input, context));
Expand All @@ -310,7 +310,7 @@ export const serializeAws_json1_1IssueCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.IssueCertificate",
"x-amz-target": "ACMPrivateCA.IssueCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1IssueCertificateRequest(input, context));
Expand All @@ -323,7 +323,7 @@ export const serializeAws_json1_1ListCertificateAuthoritiesCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.ListCertificateAuthorities",
"x-amz-target": "ACMPrivateCA.ListCertificateAuthorities",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ListCertificateAuthoritiesRequest(input, context));
Expand All @@ -336,7 +336,7 @@ export const serializeAws_json1_1ListPermissionsCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.ListPermissions",
"x-amz-target": "ACMPrivateCA.ListPermissions",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ListPermissionsRequest(input, context));
Expand All @@ -349,7 +349,7 @@ export const serializeAws_json1_1ListTagsCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.ListTags",
"x-amz-target": "ACMPrivateCA.ListTags",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ListTagsRequest(input, context));
Expand All @@ -362,7 +362,7 @@ export const serializeAws_json1_1PutPolicyCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.PutPolicy",
"x-amz-target": "ACMPrivateCA.PutPolicy",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1PutPolicyRequest(input, context));
Expand All @@ -375,7 +375,7 @@ export const serializeAws_json1_1RestoreCertificateAuthorityCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.RestoreCertificateAuthority",
"x-amz-target": "ACMPrivateCA.RestoreCertificateAuthority",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1RestoreCertificateAuthorityRequest(input, context));
Expand All @@ -388,7 +388,7 @@ export const serializeAws_json1_1RevokeCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.RevokeCertificate",
"x-amz-target": "ACMPrivateCA.RevokeCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1RevokeCertificateRequest(input, context));
Expand All @@ -401,7 +401,7 @@ export const serializeAws_json1_1TagCertificateAuthorityCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.TagCertificateAuthority",
"x-amz-target": "ACMPrivateCA.TagCertificateAuthority",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1TagCertificateAuthorityRequest(input, context));
Expand All @@ -414,7 +414,7 @@ export const serializeAws_json1_1UntagCertificateAuthorityCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.UntagCertificateAuthority",
"x-amz-target": "ACMPrivateCA.UntagCertificateAuthority",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1UntagCertificateAuthorityRequest(input, context));
Expand All @@ -427,7 +427,7 @@ export const serializeAws_json1_1UpdateCertificateAuthorityCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "ACMPrivateCA.UpdateCertificateAuthority",
"x-amz-target": "ACMPrivateCA.UpdateCertificateAuthority",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1UpdateCertificateAuthorityRequest(input, context));
Expand Down
26 changes: 13 additions & 13 deletions clients/client-acm/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const serializeAws_json1_1AddTagsToCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.AddTagsToCertificate",
"x-amz-target": "CertificateManager.AddTagsToCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1AddTagsToCertificateRequest(input, context));
Expand All @@ -107,7 +107,7 @@ export const serializeAws_json1_1DeleteCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.DeleteCertificate",
"x-amz-target": "CertificateManager.DeleteCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1DeleteCertificateRequest(input, context));
Expand All @@ -120,7 +120,7 @@ export const serializeAws_json1_1DescribeCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.DescribeCertificate",
"x-amz-target": "CertificateManager.DescribeCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1DescribeCertificateRequest(input, context));
Expand All @@ -133,7 +133,7 @@ export const serializeAws_json1_1ExportCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.ExportCertificate",
"x-amz-target": "CertificateManager.ExportCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ExportCertificateRequest(input, context));
Expand All @@ -146,7 +146,7 @@ export const serializeAws_json1_1GetCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.GetCertificate",
"x-amz-target": "CertificateManager.GetCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1GetCertificateRequest(input, context));
Expand All @@ -159,7 +159,7 @@ export const serializeAws_json1_1ImportCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.ImportCertificate",
"x-amz-target": "CertificateManager.ImportCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ImportCertificateRequest(input, context));
Expand All @@ -172,7 +172,7 @@ export const serializeAws_json1_1ListCertificatesCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.ListCertificates",
"x-amz-target": "CertificateManager.ListCertificates",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ListCertificatesRequest(input, context));
Expand All @@ -185,7 +185,7 @@ export const serializeAws_json1_1ListTagsForCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.ListTagsForCertificate",
"x-amz-target": "CertificateManager.ListTagsForCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ListTagsForCertificateRequest(input, context));
Expand All @@ -198,7 +198,7 @@ export const serializeAws_json1_1RemoveTagsFromCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.RemoveTagsFromCertificate",
"x-amz-target": "CertificateManager.RemoveTagsFromCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1RemoveTagsFromCertificateRequest(input, context));
Expand All @@ -211,7 +211,7 @@ export const serializeAws_json1_1RenewCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.RenewCertificate",
"x-amz-target": "CertificateManager.RenewCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1RenewCertificateRequest(input, context));
Expand All @@ -224,7 +224,7 @@ export const serializeAws_json1_1RequestCertificateCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.RequestCertificate",
"x-amz-target": "CertificateManager.RequestCertificate",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1RequestCertificateRequest(input, context));
Expand All @@ -237,7 +237,7 @@ export const serializeAws_json1_1ResendValidationEmailCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.ResendValidationEmail",
"x-amz-target": "CertificateManager.ResendValidationEmail",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1ResendValidationEmailRequest(input, context));
Expand All @@ -250,7 +250,7 @@ export const serializeAws_json1_1UpdateCertificateOptionsCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"X-Amz-Target": "CertificateManager.UpdateCertificateOptions",
"x-amz-target": "CertificateManager.UpdateCertificateOptions",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1UpdateCertificateOptionsRequest(input, context));
Expand Down
Loading

0 comments on commit 1308721

Please sign in to comment.