diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-02 19:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 12:05:46 +0100 |
commit | 6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch) | |
tree | fd94c013a19fcb38954844085821ec1601c20e18 /std/http/racing_server.ts | |
parent | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff) |
chore: remove std directory (#9361)
This removes the std folder from the tree.
Various parts of the tests are pretty tightly dependent
on std (47 direct imports and 75 indirect imports, not
counting the cli tests that use them as fixtures) so I've
added std as a submodule for now.
Diffstat (limited to 'std/http/racing_server.ts')
-rw-r--r-- | std/http/racing_server.ts | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/std/http/racing_server.ts b/std/http/racing_server.ts deleted file mode 100644 index b5cf69298..000000000 --- a/std/http/racing_server.ts +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -import { serve, ServerRequest } from "./server.ts"; -import { delay } from "../async/delay.ts"; - -const addr = Deno.args[1] || "127.0.0.1:4501"; -const server = serve(addr); - -function body(i: number): string { - return `Step${i}\n`; -} -async function delayedRespond( - request: ServerRequest, - step: number, -): Promise<void> { - await delay(3000); - await request.respond({ status: 200, body: body(step) }); -} - -async function largeRespond(request: ServerRequest, c: string): Promise<void> { - const b = new Uint8Array(1024 * 1024); - b.fill(c.charCodeAt(0)); - await request.respond({ status: 200, body: b }); -} - -async function ignoreToConsume( - request: ServerRequest, - step: number, -): Promise<void> { - await request.respond({ status: 200, body: body(step) }); -} - -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, step); - break; - case 2: - // HUGE body. - largeRespond(request, "a"); - break; - case 3: - // HUGE body. - largeRespond(request, "b"); - break; - case 4: - // Ignore to consume body (content-length) - ignoreToConsume(request, step); - break; - case 5: - // Ignore to consume body (chunked) - ignoreToConsume(request, step); - break; - case 6: - // Ignore to consume body (chunked + trailers) - ignoreToConsume(request, step); - break; - default: - request.respond({ status: 200, body: body(step) }); - break; - } - step++; -} |