Skip to content

Commit

Permalink
Support utf8 in file_server (denoland#3495)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan authored and ry committed Dec 14, 2019
1 parent d8e6030 commit 7e116dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion std/http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async function serveFile(
const [file, fileInfo] = await Promise.all([open(filePath), stat(filePath)]);
const headers = new Headers();
headers.set("content-length", fileInfo.len.toString());
headers.set("content-type", "text/plain");
headers.set("content-type", "text/plain; charset=utf-8");

const res = {
status: 200,
Expand Down
4 changes: 2 additions & 2 deletions std/http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ test(async function serveFile(): Promise<void> {
const res = await fetch("http:https://localhost:4500/README.md");
assert(res.headers.has("access-control-allow-origin"));
assert(res.headers.has("access-control-allow-headers"));
assert(res.headers.has("content-type"));
assert(res.headers.get("content-type").includes("charset=utf-8"));
const downloadedFile = await res.text();
const localFile = new TextDecoder().decode(
await Deno.readFile("README.md")
Expand Down Expand Up @@ -111,8 +113,6 @@ test(async function servePermissionDenied(): Promise<void> {
await errReader.readLine(),
"run again with the --allow-read flag"
);
} catch (e) {
throw e;
} finally {
deniedServer.close();
deniedServer.stdout!.close();
Expand Down

0 comments on commit 7e116dd

Please sign in to comment.