diff options
Diffstat (limited to 'std/http/io_test.ts')
-rw-r--r-- | std/http/io_test.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/std/http/io_test.ts b/std/http/io_test.ts index fd41b474e..c0f57a1b7 100644 --- a/std/http/io_test.ts +++ b/std/http/io_test.ts @@ -19,7 +19,7 @@ import { chunkedBodyReader } from "./io.ts"; import { ServerRequest, Response } from "./server.ts"; import { StringReader } from "../io/readers.ts"; import { mockConn } from "./mock.ts"; -const { Buffer, test } = Deno; +const { Buffer, test, readAll } = Deno; test("bodyReader", async () => { const text = "Hello, Deno"; @@ -357,6 +357,17 @@ test("writeResponse with trailer", async () => { assertEquals(ret, exp); }); +test("writeResponseShouldNotModifyOriginHeaders", async () => { + const headers = new Headers(); + const buf = new Deno.Buffer(); + + await writeResponse(buf, { body: "foo", headers }); + assert(decode(await readAll(buf)).includes("content-length: 3")); + + await writeResponse(buf, { body: "hello", headers }); + assert(decode(await readAll(buf)).includes("content-length: 5")); +}); + test("readRequestError", async function (): Promise<void> { const input = `GET / HTTP/1.1 malformedHeader |