From dc66fdc11e86ae060e43dbeb417738c1b1995fe6 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 12 Feb 2023 15:51:07 -0500 Subject: perf(http): remove allocations checking upgrade and connection header values (#17727) --- cli/tests/unit/http_test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cli') 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 { 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, -- cgit v1.2.3