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

add bodymixin bytes #3262

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ git sparse-checkout add /websockets
git sparse-checkout add /mimesniff
git sparse-checkout add /storage
git sparse-checkout add /service-workers
git sparse-checkout add /eventsource
```

</details>
Expand Down
9 changes: 9 additions & 0 deletions lib/web/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,15 @@ function bodyMixinMethods (instance) {
'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
)
}, instance, false)
},

bytes () {
// The bytes() method steps are to return the result of running consume body
// with this and the following step given a byte sequence bytes: return the
// result of creating a Uint8Array from bytes in this’s relevant realm.
return consumeBody(this, (bytes) => {
return new Uint8Array(bytes)
tsctx marked this conversation as resolved.
Show resolved Hide resolved
tsctx marked this conversation as resolved.
Show resolved Hide resolved
}, instance, true)
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/wpt/runner/worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ Object.defineProperties(globalThis, {
}
})

// TODO: remove once Float16Array is added. Otherwise a test throws with an uncaught exception.
globalThis.Float16Array ??= class Float16Array {}

// TODO: remove once node 18 is dropped
if (!globalThis.crypto) {
Object.defineProperty(globalThis, 'crypto', {
Expand Down
62 changes: 61 additions & 1 deletion test/wpt/status/fetch.status.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,20 @@
"Fetch with Chicken",
"Fetch with Chicken with body",
"Fetch with TacO and mode \"same-origin\" needs an Origin header",
"Fetch with TacO and mode \"cors\" needs an Origin header"
"Fetch with TacO and mode \"cors\" needs an Origin header",
"Fetch with POST with Float16Array body"
]
},
"request-private-network-headers.tentative.any.js": {
"note": "undici doesn't filter headers",
"skip": true
},
"request-upload.any.js": {
"note": "no Float16Array",
"fail": [
"Fetch with POST with Float16Array body"
]
},
"request-upload.h2.any.js": {
"note": "undici doesn't support http/2",
"skip": true
Expand Down Expand Up @@ -403,6 +410,59 @@
]
}
},
"content-encoding": {
"br": {
"bad-br-body.https.any.js": {
"note": "TODO(@KhafraDev): investigate failure",
"fail": [
"Consuming the body of a resource with bad br content with arrayBuffer() should reject"
]
},
"big-br-body.https.any.js": {
"note": "TODO(@KhafraDev): investigate failure",
"fail": [
"large br data should be decompressed successfully",
"large br data should be decompressed successfully with byte stream"
]
},
"br-body.https.any.js": {
"note": "TODO(@KhafraDev): investigate failure",
"fail": [
"fetched br data with content type text should be decompressed.",
"fetched br data with content type octetstream should be decompressed."
]
}
},
"gzip": {
"bad-gzip-body.any.js": {
"note": "TODO(@KhafraDev): investigate failure",
"fail": [
"Consuming the body of a resource with bad gzip content with arrayBuffer() should reject",
"Consuming the body of a resource with bad gzip content with blob() should reject",
"Consuming the body of a resource with bad gzip content with json() should reject",
"Consuming the body of a resource with bad gzip content with text() should reject"
]
},
"gzip-body.any.js": {
"note": "TODO(@KhafraDev): investigate failure",
"fail": [
"fetched gzip data with content type text should be decompressed.",
"fetched gzip data with content type octetstream should be decompressed."
]
},
"big-gzip-body.https.any.js": {
"note": "TODO(@KhafraDev): investigate failure",
"fail": [
"large gzip data should be decompressed successfully",
"large gzip data should be decompressed successfully with byte stream"
]
}
},
"zstd": {
"note": "node does not have zstd yet",
"skip": true
}
},
"content-length": {
"api-and-duplicate-headers.any.js": {
"fail": [
Expand Down
Loading
Loading