From 9027484ae1a9eaf9769d79828db48de66450a3fc Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Tue, 22 Aug 2023 00:30:34 -0300 Subject: fetch(stream) add stream support for compressed and uncompressed data (#4127) * streams non compressed data in 64kb chunks (at least) * fmt * wip remove pause * fix default streaming and buffering * fix atomic lags * fix size * make chunked encoding work again (WIP streaming chunked) * WIP: chunked encoding streaming * fix end of streamings * working streaming + compression * add fixes + tests * fmt + fix proxy * fix oopsies * codegen after merge * fmt + fixes * more fixes * more fixes and logs * avoid double free * check empty before pop * check empty on pop * fix copy to real when complete * remove unnecessary logs * better has_schedule_callback swap, body locked size helper, remove isEmpty from unbounded_queue pop * fix response ref, fix body_size * add deflate support, fix error throw, add more tests * codegen after merge * remove logs, add connection close test * fix macOS build * fix redirect error option * make body_size more clear * support new Reponse(response) * toString DOMWrapper objects properly instead of supporting response in Response constructor * ignore headers with no name, add more tests * oops * handle transform with fetch * add gz image stream test * remove duplicate test * fix missing chunk on macOS under pressure * oops include all OS * some fixes * compare buffers instead of sizes * refactor err.err and protect it --- test/js/web/fetch/fetch.test.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test/js/web/fetch/fetch.test.ts') diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index a381cb320..59847dde9 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -4,7 +4,7 @@ import { chmodSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSy import { mkfifo } from "mkfifo"; import { tmpdir } from "os"; import { join } from "path"; -import { gc, withoutAggressiveGC } from "harness"; +import { gc, withoutAggressiveGC, gcTick } from "harness"; const tmp_dir = mkdtempSync(join(realpathSync(tmpdir()), "fetch.test")); @@ -1334,11 +1334,18 @@ it("fetch() file:// works", async () => { expect(await (await fetch(new URL("fetch.test.ts", import.meta.url))).text()).toEqual( await Bun.file(Bun.fileURLToPath(new URL("fetch.test.ts", import.meta.url))).text(), ); - expect(await (await fetch(new URL("file with space in the name.txt", import.meta.url))).text()).toEqual( - await Bun.file(Bun.fileURLToPath(new URL("file with space in the name.txt", import.meta.url))).text(), - ); + gc(true); + var fileResponse = await fetch(new URL("file with space in the name.txt", import.meta.url)); + gc(true); + var fileResponseText = await fileResponse.text(); + gc(true); + var bunFile = Bun.file(Bun.fileURLToPath(new URL("file with space in the name.txt", import.meta.url))); + gc(true); + var bunFileText = await bunFile.text(); + gc(true); + expect(fileResponseText).toEqual(bunFileText); + gc(true); }); - it("cloned response headers are independent before accessing", () => { const response = new Response("hello", { headers: { -- cgit v1.2.3