deno
d98660cd - fix(ext/fetch): implement missing Request properties (#34607)

Commit
99 days ago
fix(ext/fetch): implement missing Request properties (#34607) ## Summary `Request` was missing properties that the [Fetch standard](https://fetch.spec.whatwg.org/#request-class) (and our own type declarations in `lib.deno_fetch.d.ts`) require. They returned `undefined`, diverging from Node.js and browsers. This PR adds the missing properties along with the corresponding `RequestInit` fields and WebIDL enum converters: - `cache` / `RequestCache` - `credentials` / `RequestCredentials` - `integrity` - `keepalive` - `mode` / `RequestMode` - `referrer` - `referrerPolicy` / `ReferrerPolicy` Defaults match the Fetch standard for a `new Request(string)`: | Property | Default | | --------------- | ---------------- | | cache | `"default"` | | credentials | `"same-origin"` | | integrity | `""` | | keepalive | `false` | | mode | `"cors"` | | referrer | `"about:client"` | | referrerPolicy | `""` | Inheritance behavior: when constructing or cloning from another `Request`, all of these inherit from the source request. Spec invariants are enforced — `mode: "navigate"` and `cache: "only-if-cached"` outside of `same-origin` mode both throw `TypeError`. The `referrer` getter serializes the internal `"client"`/`"no-referrer"` sentinels to `"about:client"` and `""` per spec. Fixes #27763. Closes denoland/orchid#352 ## Test plan - [x] `cargo build --bin deno` - [x] Added unit tests covering defaults, init reflection, inheritance from another Request, cloning, mode/cache invariants, and the special referrer values - [x] `deno test tests/unit/request_test.ts` (run against the new binary) - [x] `deno fmt --check` on touched files - [x] `deno lint` on touched files --------- Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Author
Parents
Loading