mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
Support utf8 in file_server (#3495)
This commit is contained in:
parent
d8e60309d2
commit
7e116dd70d
2 changed files with 3 additions and 3 deletions
|
@ -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,
|
||||
|
|
|
@ -36,6 +36,8 @@ test(async function serveFile(): Promise<void> {
|
|||
const res = await fetch("http://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")
|
||||
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue