diff options
author | Khải <hvksmr1996@gmail.com> | 2020-04-01 23:51:01 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-01 12:51:01 -0400 |
commit | fa7929ad2c05c5d04106800adbe944c54bd443d7 (patch) | |
tree | 5cd0b829f64e55d45787075fb19b7610394e2739 /std/http/file_server_test.ts | |
parent | 5ac2c4aa2e3018b9b997af432e6fb4803383b4d8 (diff) |
fix(file_server): use media_types for Content-Type header (#4555)
Diffstat (limited to 'std/http/file_server_test.ts')
-rw-r--r-- | std/http/file_server_test.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts index 3a3817ce0..3cb59e67f 100644 --- a/std/http/file_server_test.ts +++ b/std/http/file_server_test.ts @@ -2,6 +2,8 @@ import { assert, assertEquals, assertStrContains } from "../testing/asserts.ts"; import { BufReader } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; +import { ServerRequest } from "./server.ts"; +import { serveFile } from "./file_server.ts"; const { test } = Deno; let fileServer: Deno.Process; @@ -31,7 +33,7 @@ function killFileServer(): void { fileServer.stdout?.close(); } -test(async function serveFile(): Promise<void> { +test("file_server serveFile", async (): Promise<void> => { await startFileServer(); try { const res = await fetch("http://localhost:4500/README.md"); @@ -141,3 +143,11 @@ test(async function printHelp(): Promise<void> { helpProcess.close(); helpProcess.stdout.close(); }); + +test("contentType", async () => { + const request = new ServerRequest(); + const response = await serveFile(request, "http/testdata/hello.html"); + const contentType = response.headers!.get("content-type"); + assertEquals(contentType, "text/html; charset=utf-8"); + (response.body as Deno.File).close(); +}); |