import { describe, it, expect, beforeAll, afterAll } from "bun:test"; let url = `http://localhost:0`; let server; describe("Headers", async () => { // Start up a single server and reuse it between tests beforeAll(() => { server = Bun.serve({ fetch(req) { const hdr = req.headers.get("x-test"); return new Response(hdr); }, port: 0, }); url = `http://${server.hostname}:${server.port}`; }); afterAll(() => { server.stop(true); }); it("Headers should work", async () => { expect(await fetchContent({ "x-test": "header 1" })).toBe("header 1"); }); it("Header names must be valid", async () => { expect(() => fetch(url, { headers: { "a\tb:c": "foo" } })).toThrow("Invalid header name: 'a\tb:c'"); expect(() => fetch(url, { headers: { "❤️": "foo" } })).toThrow("Invalid header name: '❤️'"); }); it("Header values must be valid", async () => { expect(() => fetch(url, { headers: { "x-test": "\0" } })).toThrow("Header 'x-test' has invalid value: '\0'"); expect(() => fetch(url, { headers: { "x-test": "❤️" } })).toThrow("Header 'x-test' has invalid value: '❤️'"); }); it("repro 1602", async () => { const origString = "😂1234".slice(3); var encoder = new TextEncoder(); var decoder = new TextDecoder(); const roundTripString = decoder.decode(encoder.encode(origString)); expect(roundTripString).toBe(origString); // This one will pass expect(await fetchContent({ "x-test": roundTripString })).toBe(roundTripString); // This would hang expect(await fetchContent({ "x-test": origString })).toBe(origString); }); describe("toJSON()", () => { it("should provide lowercase header names", () => { const headers1 = new Headers({ "X-Test": "yep", "Content-Type": "application/json" }); expect(headers1.toJSON()).toEqual({ "x-test": "yep", "content-type": "application/json" }); const headers2 = new Headers(); headers2.append("X-Test", "yep"); headers2.append("Content-Type", "application/json"); expect(headers2.toJSON()).toEqual({ "x-test": "yep", "content-type": "application/json" }); }); }); }); async function fetchContent(headers) { const res = await fetch(url, { headers: headers }, { verbose: true }); return await res.text(); } ave/es5-class-helper'>dave/es5-class-helper Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/install/add-dev.md (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-12TweaksGravatar Colin McDonnell 1-2/+2
2023-10-12Fix structGravatar Colin McDonnell 1-1/+1
2023-10-12Clean up, implement warn_on_unrecognized_flagGravatar Colin McDonnell 4-26/+40
2023-10-12WIPGravatar Colin McDonnell 4-77/+14
2023-10-12WIPGravatar Colin McDonnell 5-347/+353
2023-10-12WIPGravatar Colin McDonnell 5-209/+446
2023-10-12WIPGravatar Colin McDonnell 2-24/+106
2023-10-12Improve helptextGravatar Colin McDonnell 1-55/+83
2023-10-12WIPGravatar Colin McDonnell 3-49/+147
2023-10-12WIPGravatar Colin McDonnell 2-0/+19
2023-10-12fix install testGravatar Dylan Conway 2-6/+8
2023-10-12fix editing package json when adding github dependency (#6432)Gravatar Dylan Conway 5-14/+146
* fix package name added to package json * check for github tag * remove alloc * some tests * fix test
2023-10-12Update installation.mdGravatar Colin McDonnell 1-8/+14
2023-10-12Update installation.mdGravatar Colin McDonnell 1-3/+3
2023-10-12fix(install): re-evaluate overrides when removedbun-v1.0.6Gravatar dave caruso 3-3/+45
2023-10-12chore: add missing ending quote (#6436)Gravatar Luna 1-1/+1
2023-10-12feat(install): support npm overrides/yarn resolutions, one level deep only ↵Gravatar dave caruso 7-31/+640
(#6435) * disable zig fmt on generated ResolvedSourceTag.zig * overrides * it works * ok * a --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-10-11fix #6416 (#6430)Gravatar Dylan Conway 2-1/+132
* make sure latest is checked after prerelease * test and fix * test for when latest matches prerelease
2023-10-11Bump WebKitGravatar Jarred Sumner 9-29/+29
2023-10-11Bump!Gravatar Jarred Sumner 1-1/+1
2023-10-11Update JSCUSocketsLoopIntegration.cppGravatar Dylan Conway 1-2/+2
2023-10-11Update installation.mdGravatar Colin McDonnell 1-10/+7