Skip to content

Commit

Permalink
fixes #50
Browse files Browse the repository at this point in the history
  • Loading branch information
amorey committed Jun 25, 2024
1 parent 1fda589 commit 27924f0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/node-http/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ export { CsrfError };
function getRequestBody(req: IncomingMessage): Promise<string> {
return new Promise((resolve, reject) => {
let body = '';
req.on('data', (chunk) => { body += chunk.toString(); });
req.on('end', () => resolve(body));

req.on('data', (chunk) => {
body += chunk.toString();
});

req.on('end', () => {
// reset body
req.push(body);
req.push(null);

// resolve promise
resolve(body);
});

req.on('error', (err) => reject(err));
});
}
Expand Down

0 comments on commit 27924f0

Please sign in to comment.