Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch: send 'sec-purpose' header for prefetch requests #3694

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Oct 7, 2024

This relates to...

Step 14 in WHATWG fetch specification https://fetch.spec.whatwg.org/#http-network-or-cache-fetch, added in whatwg/fetch#1576

Changes

Sends 'sec-purpose' header for prefetch requests as per WHATWG fetch specification

Features

N/A

Bug Fixes

N/A

Breaking Changes and Deprecations

N/A

Status

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test or enable one in the wpts?

@KhafraDev
Copy link
Member

There are no viable WPTs for server implementations

Uzlopak
Uzlopak previously requested changes Oct 7, 2024
Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments are not arbitrarely made by us, but are direct citations of the spec. Please revert the comments to match the spec.

lib/web/fetch/index.js Show resolved Hide resolved
@Uzlopak
Copy link
Contributor

Uzlopak commented Oct 7, 2024

@trivikr
I pushed changes, PTAL

@Uzlopak Uzlopak dismissed their stale review October 7, 2024 22:41

I modified it

lib/web/fetch/request.js Outdated Show resolved Hide resolved
@@ -136,7 +137,7 @@ class Request {
}

// 4. Set request to a new request whose URL is parsedURL.
request = makeRequest({ urlList: [parsedURL] })
request = makeRequest({ urlList: [parsedURL], ...init })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KhafraDev Is this right???

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

lib/web/fetch/request.js Outdated Show resolved Hide resolved
Co-authored-by: Trivikram Kamat <[email protected]>
Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.initiator will always be null therefore sec-purpose will never be added. It's fine to have the condition that adds it in case the spec ever changes, but most of the other stuff should be removed.

Comment on lines +1063 to +1068
{
key: 'initiator',
converter: webidl.converters.DOMString,
// https://fetch.spec.whatwg.org/#concept-request-initiator
allowedValues: requestInitiator
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. A Request's request (internal state) contains an initiator, not RequestInit

@@ -136,7 +137,7 @@ class Request {
}

// 4. Set request to a new request whose URL is parsedURL.
request = makeRequest({ urlList: [parsedURL] })
request = makeRequest({ urlList: [parsedURL], ...init })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants