diff options
author | 2022-05-08 01:12:46 -0700 | |
---|---|---|
committer | 2022-05-08 01:12:46 -0700 | |
commit | 61d548c7bff872d53417845d5219dc75cb7e5ecb (patch) | |
tree | f3d23ac685c545417363cde6a44559895e9fc111 /integration/bunjs-only-snippets/serve.test.ts | |
parent | c1efeefb8a481035d87ced9e01a30c9f95e0c2eb (diff) | |
download | bun-61d548c7bff872d53417845d5219dc75cb7e5ecb.tar.gz bun-61d548c7bff872d53417845d5219dc75cb7e5ecb.tar.zst bun-61d548c7bff872d53417845d5219dc75cb7e5ecb.zip |
[bun.js] Fix bug with headers not being sent in `fetch`
Diffstat (limited to 'integration/bunjs-only-snippets/serve.test.ts')
-rw-r--r-- | integration/bunjs-only-snippets/serve.test.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/serve.test.ts b/integration/bunjs-only-snippets/serve.test.ts index 323caf1f8..653454cc3 100644 --- a/integration/bunjs-only-snippets/serve.test.ts +++ b/integration/bunjs-only-snippets/serve.test.ts @@ -32,6 +32,28 @@ it("should work for a file", async () => { server.stop(); }); +it("fetch should work with headers", async () => { + const fixture = resolve(import.meta.dir, "./fetch.js.txt"); + + const server = serve({ + port: port++, + fetch(req) { + if (req.headers.get("X-Foo") !== "bar") { + return new Response("X-Foo header not set", { status: 500 }); + } + return new Response(file(fixture)); + }, + }); + const response = await fetch(`http://localhost:${server.port}`, { + headers: { + "X-Foo": "bar", + }, + }); + + expect(response.status).toBe(200); + server.stop(); +}); + var count = 200; it(`should work for a file ${count} times`, async () => { const fixture = resolve(import.meta.dir, "./fetch.js.txt"); |