0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

fix: appended CRLF to end of trailer headers (#3989)

This commit is contained in:
Yusuke Sakurai 2020-02-14 06:05:30 +09:00 committed by GitHub
parent 9325744a94
commit 621aeef836
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -84,6 +84,7 @@ export async function writeTrailers(
); );
await writer.write(encoder.encode(`${key}: ${value}\r\n`)); await writer.write(encoder.encode(`${key}: ${value}\r\n`));
} }
await writer.write(encoder.encode("\r\n"));
await writer.flush(); await writer.flush();
} }

View file

@ -456,6 +456,7 @@ test("writeResponse with trailer", async () => {
"", "",
"deno: land", "deno: land",
"node: js", "node: js",
"",
"" ""
].join("\r\n"); ].join("\r\n");
assertEquals(ret, exp); assertEquals(ret, exp);
@ -775,7 +776,7 @@ test("writeTrailer", async () => {
new Headers({ "transfer-encoding": "chunked", trailer: "deno,node" }), new Headers({ "transfer-encoding": "chunked", trailer: "deno,node" }),
new Headers({ deno: "land", node: "js" }) new Headers({ deno: "land", node: "js" })
); );
assertEquals(w.toString(), "deno: land\r\nnode: js\r\n"); assertEquals(w.toString(), "deno: land\r\nnode: js\r\n\r\n");
}); });
test("writeTrailer should throw", async () => { test("writeTrailer should throw", async () => {