fix(http): support binary request bodies#8478
Open
iamanaws wants to merge 1 commit into
Open
Conversation
9cbdc0b to
5bfdb1d
Compare
|
@iamanaws Woop woop, thank you so much for this contribution! |
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.
Description
Fix patched
fetchsupport for binary request bodies.This updates the native HTTP bridge path so
fetch()requests withBlob/binary bodies preserve the original bytes instead of serializing the body as{}.Change Type
Rationale / Problems Fixed
Related issue: #6177
Specific repro comment: #6177 (comment)
I updated the original HTTP/fetch repro to the latest Capacitor version here:
https://github.com/iamanaws/capacitor-http-tester
The original HTTP/fetch cases from the issue now pass for me on web, Android, and iOS, but one binary request-body issue remained: a plain
fetch()POST with aBlobbody works on web, but native Capacitor patchedfetchdid not preserve the Blob bytes correctly.Observed Android result before this fix:
{ "contentType": "application/octet-stream", "length": 2, "text": "{}" }This looks similar to #6126, but for sending a Blob instead of receiving one.
This also breaks floccus (floccusaddon/floccus#1608) because isomorphic-git/http/web uses fetch, and Git smart HTTP needs binary request bodies.
Tests or Reproductions
Failing repro on current Capacitor version:
https://github.com/iamanaws/capacitor-http-tester
Proof branch using this Capacitor patch (from local source):
https://github.com/iamanaws/capacitor-http-tester/tree/repro/binary-request-body-support
Tested with the repro app on Android, iOS, and Web
With this patch, the Blob request-body test passes on Android and iOS.
Screenshots / Media
N/A
Platforms Affected
Notes / Comments
Web already preserves the Blob body correctly. This PR fixes native patched fetch request body handling.