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("\r\n"));
await writer.flush();
}

View File

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