Skip to content

fix: preserve binary proxy request bodies - #158

Open
jztdjfcsdj wants to merge 2 commits into
tscircuit:mainfrom
jztdjfcsdj:codex/preserve-proxy-body
Open

jztdjfcsdj wants to merge 2 commits into
tscircuit:mainfrom
jztdjfcsdj:codex/preserve-proxy-body

Conversation

@jztdjfcsdj

Copy link
Copy Markdown

/proxy reads POST, PUT, and PATCH bodies as text. Invalid UTF-8 bytes are replaced during decoding, so a payload of 00 ff fe 80 41 arrives upstream as 00 ef bf bd ef bf bd ef bf bd 41. DELETE and OPTIONS bodies are dropped altogether, even though these methods are supported by the route.

Read the body as an ArrayBuffer for every supported method except GET and HEAD. This preserves the original bytes and forwards bodies for DELETE and OPTIONS as well.

Five local echo-server regression cases cover POST, PUT, PATCH, DELETE, and OPTIONS. All five fail on the unchanged source and pass with the fix.

Validation with Bun 1.4.2 on Windows:

  • bun test: 34 passed, 0 failed (180 assertions), including existing GET and JSON POST coverage.
  • bun x --no-install tsc --noEmit: passed.
  • Biome formatting check on changed files: passed.
  • The full Windows bundle build is not verified. An unchanged checkout of the same source fails in Winterspec's generated import path escaping (routes/files/upsert.ts); the baseline log is retained locally.

Prepared with AI assistance; the listed tests were executed locally. This change is independent of the previously rewarded download-endpoint issue #5.

If you accept paid contributions for small fixes, would you consider a $3 reward? This is a compensation request, not a claim against an existing funded bounty.

Fixes #157.

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.

Proxy corrupts binary request bodies and drops DELETE/OPTIONS bodies (tested fix)

1 participant