mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
Use top-level for-await in various places (#3217)
This commit is contained in:
parent
71efe6f2c5
commit
f484776384
9 changed files with 94 additions and 125 deletions
|
@ -19,32 +19,28 @@ async function largeRespond(request: ServerRequest, c: string): Promise<void> {
|
|||
await request.respond({ status: 200, body: b });
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
let step = 1;
|
||||
for await (const request of server) {
|
||||
switch (step) {
|
||||
case 1:
|
||||
// Try to wait long enough.
|
||||
// For pipelining, this should cause all the following response
|
||||
// to block.
|
||||
delayedRespond(request);
|
||||
break;
|
||||
case 2:
|
||||
// HUGE body.
|
||||
largeRespond(request, "a");
|
||||
break;
|
||||
case 3:
|
||||
// HUGE body.
|
||||
largeRespond(request, "b");
|
||||
break;
|
||||
default:
|
||||
request.respond({ status: 200, body: body4 });
|
||||
break;
|
||||
}
|
||||
step++;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
console.log("Racing server listening...\n");
|
||||
|
||||
let step = 1;
|
||||
for await (const request of server) {
|
||||
switch (step) {
|
||||
case 1:
|
||||
// Try to wait long enough.
|
||||
// For pipelining, this should cause all the following response
|
||||
// to block.
|
||||
delayedRespond(request);
|
||||
break;
|
||||
case 2:
|
||||
// HUGE body.
|
||||
largeRespond(request, "a");
|
||||
break;
|
||||
case 3:
|
||||
// HUGE body.
|
||||
largeRespond(request, "b");
|
||||
break;
|
||||
default:
|
||||
request.respond({ status: 200, body: body4 });
|
||||
break;
|
||||
}
|
||||
step++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue