From d308e8d0c0469419517e05a36ba070633168dc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 29 Apr 2020 22:38:10 +0200 Subject: BREAKING: remove custom implementation of Deno.Buffer.toString() (#4992) Keep in mind Buffer.toString() still exists, but returns [object Object]. Reason for removal of Buffer.toString() was that it implicitly used TextDecoder with fixed "utf-8" encoding and no way to customize the encoding. --- std/http/io_test.ts | 9 ++++++--- std/http/server_test.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'std/http') diff --git a/std/http/io_test.ts b/std/http/io_test.ts index b9bb56f11..fd41b474e 100644 --- a/std/http/io_test.ts +++ b/std/http/io_test.ts @@ -51,7 +51,7 @@ test("chunkedBodyReader", async () => { await dest.write(buf.subarray(0, len)); } const exp = "aaabbbbbcccccccccccdddddddddddddddddddddd"; - assertEquals(dest.toString(), exp); + assertEquals(new TextDecoder().decode(dest.bytes()), exp); }); test("chunkedBodyReader with trailers", async () => { @@ -133,7 +133,10 @@ 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\r\n"); + assertEquals( + new TextDecoder().decode(w.bytes()), + "deno: land\r\nnode: js\r\n\r\n" + ); }); test("writeTrailer should throw", async () => { @@ -336,7 +339,7 @@ test("writeResponse with trailer", async () => { body, trailers: () => new Headers({ deno: "land", node: "js" }), }); - const ret = w.toString(); + const ret = new TextDecoder().decode(w.bytes()); const exp = [ "HTTP/1.1 200 OK", "transfer-encoding: chunked", diff --git a/std/http/server_test.ts b/std/http/server_test.ts index 4e7b4b69e..03256dd25 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -63,7 +63,7 @@ test("responseWrite", async function (): Promise { request.conn = mockConn(); await request.respond(testCase.response); - assertEquals(buf.toString(), testCase.raw); + assertEquals(new TextDecoder().decode(buf.bytes()), testCase.raw); await request.done; } }); -- cgit v1.2.3