summaryrefslogtreecommitdiff
path: root/http/server.ts
diff options
context:
space:
mode:
authorJun Kato <i@junkato.jp>2019-05-11 01:55:18 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-05-14 17:28:15 -0400
commit7cc80064f0742c9069310fbe8fb42fdf58b7df8d (patch)
tree61f837c73bf0eec8e726b7e50a68995b52e73631 /http/server.ts
parent1b359f4106891f2f07c334da683822070b24374f (diff)
fix(http): Skip 0 chunks when writing body (denoland/deno_std#387)
Original: https://github.com/denoland/deno_std/commit/79d5f556ba22d6fa9426825234cc8c49d37caf2c
Diffstat (limited to 'http/server.ts')
-rw-r--r--http/server.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/http/server.ts b/http/server.ts
index 0892b26f7..484ecf808 100644
--- a/http/server.ts
+++ b/http/server.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-const { listen, toAsyncIterator, copy } = Deno;
+const { listen, copy, toAsyncIterator } = Deno;
type Conn = Deno.Conn;
type Reader = Deno.Reader;
type Writer = Deno.Writer;
@@ -79,6 +79,7 @@ async function writeChunkedBody(w: Writer, r: Reader): Promise<void> {
const encoder = new TextEncoder();
for await (const chunk of toAsyncIterator(r)) {
+ if (chunk.byteLength <= 0) continue;
const start = encoder.encode(`${chunk.byteLength.toString(16)}\r\n`);
const end = encoder.encode("\r\n");
await writer.write(start);