-
Notifications
You must be signed in to change notification settings - Fork 330
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 a method to get a Uint8Array to Body #1732
Labels
Comments
bakkot
added
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
labels
Jan 29, 2024
FWIW, WebKit is okay with adding this. cc @valenting @ricea |
Sounds good to me, but I'd like @saschanaz 's opinion as well. |
Sounds okay to me. |
annevk
added
needs concrete proposal
Moving the issue forward requires someone to figure out a detailed plan
and removed
needs implementer interest
Moving the issue forward requires implementers to express interest
labels
Apr 4, 2024
Chromium supports. |
This was referenced May 4, 2024
This was referenced May 13, 2024
annevk
pushed a commit
that referenced
this issue
May 14, 2024
Returns a Uint8Array as opposed to requiring users to get an ArrayBuffer and wrap it. Tests: web-platform-tests/wpt#46198. Fixes #1732.
annevk
removed
the
needs concrete proposal
Moving the issue forward requires someone to figure out a detailed plan
label
May 26, 2024
aarongable
pushed a commit
to chromium/chromium
that referenced
this issue
Oct 3, 2024
This CL adds a bytes() method to get Uint8Array to body, instead of requiring users to get an ArrayBuffer with arrayBuffer() and wrap it. whatwg/fetch#1732 https://chromestatus.com/feature/5239268180754432 Bug: 340206277 Change-Id: I48a96970450592bcbae7d0a8b79f68b9bd0b556b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5895865 Reviewed-by: Rick Byers <[email protected]> Reviewed-by: Adam Rice <[email protected]> Commit-Queue: Perry <[email protected]> Cr-Commit-Position: refs/heads/main@{#1363676}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem are you trying to solve?
Body has an
.arrayBuffer()
method, but that's almost never what you actually want, since you can't read out of a buffer directly - you need a view. Uint8Array is the canonical "sequence of byte values" view.What solutions exist today?
new Uint8Array(await body.arrayBuffer())
How would you solve it?
Add a
.bytes()
method which gives a newUint8Array
.Anything else?
Some brief discussion here.
PushMessageData and Blob (which live elsewhere) would need this too, since they just copied Body.
(Also, watch out for #1675 while specifying.)
The text was updated successfully, but these errors were encountered: