From 621aeef8364fcbd2da93b208971c51a4fbf08903 Mon Sep 17 00:00:00 2001 From: Yusuke Sakurai Date: Fri, 14 Feb 2020 06:05:30 +0900 Subject: [PATCH] fix: appended CRLF to end of trailer headers (#3989) --- std/http/server.ts | 1 + std/http/server_test.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/std/http/server.ts b/std/http/server.ts index b8a41379f0..c6a895a1fd 100644 --- a/std/http/server.ts +++ b/std/http/server.ts @@ -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(); } diff --git a/std/http/server_test.ts b/std/http/server_test.ts index a18cd273c8..123bc7155c 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -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 () => {