diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-02-12 15:51:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-12 20:51:07 +0000 |
commit | dc66fdc11e86ae060e43dbeb417738c1b1995fe6 (patch) | |
tree | 4c66594ef13faaa28a793467e57782d7939cfbf2 /cli/tests/unit | |
parent | fc843d035c0cb4936d9b87670e282667a9a8b265 (diff) |
perf(http): remove allocations checking upgrade and connection header values (#17727)
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/http_test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts index 73ff35e09..570399841 100644 --- a/cli/tests/unit/http_test.ts +++ b/cli/tests/unit/http_test.ts @@ -14,6 +14,11 @@ import { } from "./test_util.ts"; import { join } from "../../../test_util/std/path/mod.ts"; +const { + buildCaseInsensitiveCommaValueFinder, + // @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol +} = Deno[Deno.internal]; + async function writeRequestAndReadResponse(conn: Deno.Conn): Promise<string> { const encoder = new TextEncoder(); const decoder = new TextDecoder(); @@ -2612,6 +2617,30 @@ Deno.test({ }, }); +Deno.test("case insensitive comma value finder", async (t) => { + const cases = /** @type {[string, boolean][]} */ ([ + ["websocket", true], + ["wEbSOcKET", true], + [",wEbSOcKET", true], + [",wEbSOcKET,", true], + [", wEbSOcKET ,", true], + ["test, wEbSOcKET ,", true], + ["test ,\twEbSOcKET\t\t ,", true], + ["test , wEbSOcKET", true], + ["test, asdf,web,wEbSOcKET", true], + ["test, asdf,web,wEbSOcKETs", false], + ["test, asdf,awebsocket,wEbSOcKETs", false], + ]); + + const findValue = buildCaseInsensitiveCommaValueFinder("websocket"); + for (const [input, expected] of cases) { + await t.step(input.toString(), () => { + const actual = findValue(input); + assertEquals(actual, expected); + }); + } +}); + async function httpServerWithErrorBody( listener: Deno.Listener, compression: boolean, |