Files
bun.sh/src/http/FetchRequestMode.zig
robobun ad4aabf486 fix(Request): set cache and mode options correctly (#26099)
## Summary

- `new Request()` was ignoring `cache` and `mode` options, always
returning hardcoded default values ("default" for cache, "navigate" for
mode)
- Added proper storage and handling of these options in the Request
struct
- Both options are now correctly parsed from the constructor init object
and preserved when cloning

Fixes #2993

## Test plan

- [x] Added regression test in `test/regression/issue/2993.test.ts`
- [x] Tests verify all valid cache values: "default", "no-store",
"reload", "no-cache", "force-cache", "only-if-cached"
- [x] Tests verify all valid mode values: "same-origin", "no-cors",
"cors", "navigate"
- [x] Tests verify default values (cache: "default", mode: "cors")
- [x] Tests verify `Request.clone()` preserves options
- [x] Tests verify `new Request(request)` preserves options
- [x] Tests verify `new Request(request, init)` allows overriding
options


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 23:02:16 -08:00

17 lines
416 B
Zig

/// https://developer.mozilla.org/en-US/docs/Web/API/Request/mode
pub const FetchRequestMode = enum(u2) {
@"same-origin",
@"no-cors",
cors,
navigate,
pub const Map = bun.ComptimeStringMap(FetchRequestMode, .{
.{ "same-origin", .@"same-origin" },
.{ "no-cors", .@"no-cors" },
.{ "cors", .cors },
.{ "navigate", .navigate },
});
};
const bun = @import("bun");