Bound a request body
Take your time, follow the code and check your understanding.
The codeNode.js requests and async
let body = "";
for await (const chunk of req) {
body += chunk;
}
// Accepts a body of any size.Your answer4 min · no timer
Show solution and explanation
Enforce a byte limit while reading the stream, including when Content-Length is missing or inaccurate. Reject an oversized body before parsing it.
Count incoming bytes and reject a body over the limit.