Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b4f10c9

Browse files
committedApr 20, 2019
expose empty body as empty string
1 parent ff8817e commit b4f10c9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎src/utils/serve-functions.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ function createHandler(dir) {
177177
var isBase64Encoded = false;
178178
var body = request.body;
179179

180-
if (body instanceof Buffer) {
180+
if (body === undefined || Object.keys(body).length === 0) {
181+
// handle empty body (https://github.com/expressjs/body-parser/issues/288)
182+
body = "";
183+
} else if (body instanceof Buffer) {
181184
isBase64Encoded = true;
182185
body = body.toString("base64");
183-
} else if(body.toString) {
184-
isBase64Encoded = false;
185-
body = body.toString();
186+
} else if(typeof(body) === "string") {
187+
// body is already processed as string
186188
}
187189

188190
const lambdaRequest = {

0 commit comments

Comments
 (0)
This repository has been archived.