maxm-reportbodysize.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export default async function(req: Request): Promise<Response> {
if (req.method !== "POST") {
return new Response("Method not allowed", { status: 405 });
}
const reader = req.body.getReader();
let totalBytes = 0;
console.log(performance.now());
while (true) {
const { done, value } = await reader.read();
if (done) break;
console.log(value.byteLength, performance.now());
totalBytes += value.byteLength;
}
return new Response(`${totalBytes}`);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v5
June 12, 2024