diff options
author | 2023-01-24 02:31:45 -0800 | |
---|---|---|
committer | 2023-01-24 02:31:45 -0800 | |
commit | 63403741ff04a1e04fd7e8f4304cb2ccd233aeed (patch) | |
tree | 12e535af98a15176ef35fd8dc5ef40707606980f /test/bun.js/proxy.test.js | |
parent | 66643a5b5721ff8c2042b5d3b86db7f920403502 (diff) | |
download | bun-63403741ff04a1e04fd7e8f4304cb2ccd233aeed.tar.gz bun-63403741ff04a1e04fd7e8f4304cb2ccd233aeed.tar.zst bun-63403741ff04a1e04fd7e8f4304cb2ccd233aeed.zip |
flaky
Diffstat (limited to 'test/bun.js/proxy.test.js')
-rw-r--r-- | test/bun.js/proxy.test.js | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/test/bun.js/proxy.test.js b/test/bun.js/proxy.test.js index 32b21f7e8..5f4be2338 100644 --- a/test/bun.js/proxy.test.js +++ b/test/bun.js/proxy.test.js @@ -5,35 +5,37 @@ let proxy, server; // TODO: Proxy with TLS requests -beforeAll(()=> { +beforeAll(() => { proxy = Bun.serve({ async fetch(request) { // if is not an proxy connection just drop it if (!request.headers.has("proxy-connection")) { return new Response("Bad Request", { status: 400 }); } - + // simple http proxy if (request.url.startsWith("http://")) { - return await fetch(request.url, { method: request.method, body: await request.text() }); + return await fetch(request.url, { + method: request.method, + body: await request.text(), + }); } - + // no TLS support here return new Response("Bad Request", { status: 400 }); - }, - port: 54321, - }); + port: 54312, + }); server = Bun.serve({ async fetch(request) { - if (request.method === "POST"){ + if (request.method === "POST") { const text = await request.text(); - return new Response(text,{ status: 200 }); + return new Response(text, { status: 200 }); } - return new Response("Hello, World",{ status: 200 }); + return new Response("Hello, World", { status: 200 }); }, port: 54322, - }); + }); }); afterAll(() => { @@ -43,10 +45,21 @@ afterAll(() => { describe("proxy", () => { const requests = [ - [ new Request("http://localhost:54322"), "fetch() GET with non-TLS Proxy", "http://localhost:54321"], - [ new Request("http://localhost:54322", { method: "POST", body: "Hello, World" }), "fetch() POST with non-TLS Proxy", "http://localhost:54321"] + [ + new Request("http://localhost:54322"), + "fetch() GET with non-TLS Proxy", + "http://localhost:54312", + ], + [ + new Request("http://localhost:54322", { + method: "POST", + body: "Hello, World", + }), + "fetch() POST with non-TLS Proxy", + "http://localhost:54312", + ], ]; - for (let [ request, name, proxy ] of requests) { + for (let [request, name, proxy] of requests) { gc(); it(name, async () => { gc(); @@ -57,4 +70,4 @@ describe("proxy", () => { expect(text).toBe("Hello, World"); }); } -});
\ No newline at end of file +}); |