Skip to content

fix(http): support binary request bodies#8478

Open
iamanaws wants to merge 1 commit into
ionic-team:mainfrom
iamanaws:fix/http-binary-request-bodies
Open

fix(http): support binary request bodies#8478
iamanaws wants to merge 1 commit into
ionic-team:mainfrom
iamanaws:fix/http-binary-request-bodies

Conversation

@iamanaws
Copy link
Copy Markdown

@iamanaws iamanaws commented May 23, 2026

Description

Fix patched fetch support for binary request bodies.

This updates the native HTTP bridge path so fetch() requests with Blob/binary bodies preserve the original bytes instead of serializing the body as {}.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation

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 a Blob body works on web, but native Capacitor patched fetch did 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

  • Android
  • iOS
  • Web

Notes / Comments

Web already preserves the Blob body correctly. This PR fixes native patched fetch request body handling.

@iamanaws iamanaws marked this pull request as ready for review May 23, 2026 22:33
@iamanaws iamanaws force-pushed the fix/http-binary-request-bodies branch from 9cbdc0b to 5bfdb1d Compare May 23, 2026 22:56
@marcelklehr
Copy link
Copy Markdown

@iamanaws Woop woop, thank you so much for this contribution!

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.

2 participants