Repository navigation
fix(http): send typed array, DataView and Blob request bodies - #11654
Merged
Merged
Conversation
4 of 5 tasks
|
View your CI Pipeline Execution ↗ for commit 9b5dd23
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
NathanWalker
approved these changes
Nov 21, 2026
NathanWalker
left a comment
Contributor
There was a problem hiding this comment.
Great catch on both the dropped ArrayBufferView / Blob request bodies and Blob copying the full backing ArrayBuffer instead of [byteOffset, byteOffset + byteLength]. The padded sub-view tests across xhr, fetch, and http.request give solid coverage (and test-ios passed on CI too).
Two small optional follow-ups (non-blocking):
HttpRequestOptions.contentinhttp-interfaces.tscould widen fromUint8ArraytoArrayBufferViewsoDataView/ other typed arrays type-check directly onhttp.request.- On iOS,
NSData.dataWithBytesLength(bytes as any, bytes.byteLength)(as inFileSystemAccess.getBuffer) could avoid the extrabuffer.slicecopy for sub-views.
Good to merge once #11636 lands.
farfromrefug
approved these changes
Nov 21, 2026
HttpRequestOptions.content accepts a Uint8Array, but the Android and iOS request layers only sent string, FormData and ArrayBuffer content, so any other body went out empty. That covered xhr.send(blob), whose content is the Blob's Uint8Array, and fetch() with a typed array or DataView body. xhr.send(typedArrayOrDataView) never set the content at all. Both platforms now send any ArrayBuffer view as exactly the bytes it covers, and xhr.send passes views through. The Blob constructor copied a view's whole underlying buffer instead of the bytes the view covers, so a Blob built from a subarray held extra bytes; it now copies only the view's range.
NathanWalker
force-pushed
the
fix/http-binary-request-bodies
branch
from
November 27, 2026 22:26
c20960a to
9b5dd23
Compare
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
HttpRequestOptions.contentis typedstring | FormData | ArrayBuffer | Uint8Array, but the Android and iOS request layers only sendstring,FormDataandArrayBuffercontent. Anything else goes out as an empty body, with no error:xhr.send(blob): the content is the Blob's internalUint8Array;xhr.send(typedArray)andxhr.send(dataView): the content is never set;fetch(url, { body })with a typed array,DataVieworBlob, which all go throughxhr.send;http.request({ content: uint8Array }).Separately,
new Blob([view])copied the view's whole underlying buffer instead of the bytes the view covers, so a Blob built from asubarrayheld extra bytes.What is the new behavior?
getRequestBodyBytes()returns anArrayBufferor anyArrayBufferview as aUint8Arrayover exactly the bytes it covers, without copying.ArrayBufferbodies, including the fast path from perf(http): native buffer copies for Android request and response bodies #11636 on newer runtimes.NSData. A view that covers its whole buffer is passed as that buffer; otherwise only its range is copied out first.xhr.sendpasses typed arrays andDataViews through.Blobconstructor copies only the range a view covers.Verification
getRequestBodyBytes(ArrayBuffer, aUint16Arraysub-view, aDataView, non-binary content).apps/automatedtests post JSON throughxhr.send(typed array,DataView,Blob),fetch(typed array) andhttp.request(typed array) to the echo server and check the parsed JSON. Every body is a view in the middle of a buffer padded withxbytes, so a dropped body or an ignoredbyteOffsetfails the test.apps/automatedsuite on an Android emulator (API 36): 1701 OK, 0 failed on@nativescript/android9.1.1, and 1701 OK, 0 failed on a runtime built from android#2102 (9.1.3-pr2102), which takes the direct typed-array copy path. All five new tests pass on both.NSData.dataWithData(ArrayBuffer)call.Stacked on #11636.