mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 01:50:30 +00:00
fix: use server-side fetch header permissions for extensions
This commit is contained in:
1 parent
fe2f45e40d
commit
342c55fbd6
6 files changed
+303
-89
No files matched your search
+24
-7
@@ -9,7 +9,7 @@ The files under `fetch/` are copied from the official
|
||||
|
||||
Gopeed executes applicable worker-style Fetch API tests at the extension
|
||||
JavaScript boundary. The checked-in runner currently executes unchanged WPT
|
||||
tests for Headers, no-CORS header guards, Request construction and body
|
||||
tests for Headers syntax and iteration, Request construction and body
|
||||
consumption, ReadableStream bodies, keepalive, Request errors, Response
|
||||
construction and body consumption, immutable network response headers, and
|
||||
the Response static constructors.
|
||||
@@ -23,12 +23,29 @@ keeps extension-specific behavior: `redirect: "manual"` exposes the HTTP
|
||||
redirect response so download extensions can inspect `Location`, instead of
|
||||
returning a browser `opaqueredirect` response.
|
||||
|
||||
Extensions may also supply an explicit `Cookie` request header, including in
|
||||
`no-cors` mode. The runner excludes the single upstream assertion that treats
|
||||
`Cookie` as an invalid request header; Gopeed integration tests instead verify
|
||||
that fetch and XMLHttpRequest send it to the server. `credentials: "omit"`
|
||||
disables automatic CookieJar cookies but preserves an explicit header. Other
|
||||
request header guards remain covered by the unchanged upstream tests.
|
||||
Header permissions follow [Node/Undici's server-side Fetch API](https://github.com/nodejs/undici/blob/main/README.md#forbidden-and-safelisted-header-names). Gopeed does not
|
||||
apply browser forbidden request/response header lists or no-CORS safelists.
|
||||
Extensions may supply authentication, referrer, origin, host, proxy and fetch
|
||||
metadata headers, and read `Set-Cookie` response headers. Network response
|
||||
headers remain immutable; invalid header syntax still raises an error.
|
||||
Repeated `Cookie` values are combined with `; `, as in Node/Undici.
|
||||
|
||||
The runner excludes the browser-only `headers-no-cors.any.js` and
|
||||
`headers-forbidden-override.any.js` suites, the filtering assertions within
|
||||
`request-headers.any.js`, and the forbidden-response-cookie assertion within
|
||||
`header-setcookie.any.js`. Gopeed's `extension_headers_test.go` replaces those
|
||||
restrictions with integration tests that check headers actually received by
|
||||
an HTTP server through fetch and XMLHttpRequest, plus header mutations,
|
||||
cloning and response cookies. The upstream test files remain unchanged.
|
||||
|
||||
Gopeed deliberately ignores transport controls that Node/Undici rejects:
|
||||
`Expect`, `Keep-Alive`, `Transfer-Encoding`, `Upgrade`, and `Connection` values
|
||||
other than `close` or `keep-alive`. `Content-Length` is generated from the
|
||||
actual request body, ignoring a supplied length. Explicit `Host` and
|
||||
`Sec-Fetch-Mode` values are preserved rather than replaced by defaults.
|
||||
These transport behaviors are also covered by integration tests.
|
||||
`credentials: "omit"` disables automatic CookieJar cookies but preserves
|
||||
explicit headers; Gopeed retains its extension CookieJar support.
|
||||
|
||||
`wpt_harness.js` is a small Goja adapter maintained by Gopeed; it is not copied
|
||||
from WPT. Test logic below `fetch/` is unchanged; the checked-in copy may only
|
||||
|
||||
Reference in new issue
Block a user