From fa7929ad2c05c5d04106800adbe944c54bd443d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kh=E1=BA=A3i?= Date: Wed, 1 Apr 2020 23:51:01 +0700 Subject: fix(file_server): use media_types for Content-Type header (#4555) --- std/http/file_server_test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'std/http/file_server_test.ts') 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 { +test("file_server serveFile", async (): Promise => { await startFileServer(); try { const res = await fetch("http://localhost:4500/README.md"); @@ -141,3 +143,11 @@ test(async function printHelp(): Promise { 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(); +}); -- cgit v1.2.3