Skip to content

Commit

Permalink
fix: properly calculate content-length for cfn custom resource respon…
Browse files Browse the repository at this point in the history
…ses (#3584)
  • Loading branch information
auvred committed Jan 10, 2024
1 parent d45f36c commit 5201a37
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-windows-lick.md
@@ -0,0 +1,5 @@
---
"sst": patch
---

Properly calculate content-length for cfn custom resource responses
2 changes: 1 addition & 1 deletion packages/sst/support/certificate-requestor/index.mjs
Expand Up @@ -54,7 +54,7 @@ let report = function (
method: "PUT",
headers: {
"Content-Type": "",
"Content-Length": responseBody.length,
"Content-Length": Buffer.byteLength(responseBody.length, "utf-8"),
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/sst/support/custom-resources/cfn-response.ts
Expand Up @@ -53,7 +53,7 @@ export async function submitResponse(
method: "PUT",
headers: {
"content-type": "",
"content-length": responseBody.length,
"content-length": Buffer.byteLength(responseBody.length, "utf-8"),
},
},
responseBody
Expand Down
2 changes: 1 addition & 1 deletion packages/sst/support/edge-function/cfn-response.ts
Expand Up @@ -51,7 +51,7 @@ export async function submitResponse(
method: "PUT",
headers: {
"content-type": "",
"content-length": responseBody.length,
"content-length": Buffer.byteLength(responseBody.length, "utf-8"),
},
},
responseBody
Expand Down
2 changes: 1 addition & 1 deletion packages/sst/support/script-function/cfn-response.ts
Expand Up @@ -53,7 +53,7 @@ export async function submitResponse(
method: "PUT",
headers: {
"content-type": "",
"content-length": responseBody.length,
"content-length": Buffer.byteLength(responseBody.length, "utf-8"),
},
},
responseBody
Expand Down
Expand Up @@ -144,7 +144,7 @@ def cfn_send(event, context, responseStatus, responseData={}, physicalResourceId

headers = {
'content-type' : '',
'content-length' : str(len(body))
'content-length' : str(len(body.encode('utf-8')))
}

try:
Expand Down

0 comments on commit 5201a37

Please sign in to comment.