Skip to content

feat: return binary response bodies as base64 on request - #10

Merged
tygoegmond merged 1 commit into
mainfrom
feat/binary-response-bodies
Oct 9, 2026
Merged

tygoegmond merged 1 commit into
mainfrom
feat/binary-response-bodies

Conversation

@tygoegmond

Copy link
Copy Markdown
Contributor

http.request and http.session.request take an optional responseBody: text (the default, as today) or base64.

Today both shells decode a response body as UTF-8 (iOS String(decoding:as: UTF8.self), Android String(bytes, UTF_8)), which replaces bytes that aren't UTF-8. A binary body can't reach the page intact. The Link UI needs one: a Versinetic charger (Volt Time Source, Ratio io7) hands out its transaction history only as a .tar.gz download. With responseBody: "base64" the shell answers the body's bytes as base64, and the page decodes it.

  • iOS: HTTP1.ResponseBody (text, base64), on HTTPSessions.Request and HTTPService.Request, parsed by Bridge.responseBody.
  • Android: Http1.ResponseBody, on HttpSessions.Request and in LocalNetworkClient.request.
  • Anything other than text or base64 is invalidParams. Absent keeps today's behaviour, so existing pages are unchanged.
  • PROTOCOL §9.2 and §9.5 document it.

Tests: iOS HTTPSessionTests, RequestParamsTests, HTTP1Tests, TLSSessionTests (71, simulator); Android Http1Test, HttpSessionsTest (36).

http.request and http.session.request take an optional responseBody, text (the default) or base64. Text decodes the body as UTF-8, which replaces bytes that aren't UTF-8, so a binary body such as a charger's transaction archive couldn't reach the page intact. base64 answers the body's bytes as base64.
@tygoegmond
tygoegmond merged commit 5a71ad1 into main Oct 9, 2026
4 checks passed
@tygoegmond
tygoegmond deleted the feat/binary-response-bodies branch October 9, 2026 12:22
tygoegmond pushed a commit that referenced this pull request Oct 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.6.0](0.5.0...0.6.0)
(2026-10-09)


### Features

* return binary response bodies as base64 on request
([#10](#10))
([5a71ad1](5a71ad1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant