Skip to content

fix: stream non-textual responses through untouched#55

Open
erichurkman wants to merge 1 commit into
draphy:v1from
erichurkman:fix/proxy-binary-passthrough
Open

fix: stream non-textual responses through untouched#55
erichurkman wants to merge 1 commit into
draphy:v1from
erichurkman:fix/proxy-binary-passthrough

Conversation

@erichurkman

Copy link
Copy Markdown

Non-textual responses (PDFs, fonts, and other file attachments upstream in Notion) were being read with response.text(), which does a lossy UTF-8 decode/re-encode round-trip that corrupts the bytes. The browser then receives a broken file and can't render it. (Saw this specifically with PDFs.)

Detect the content-type and pass binary bodies straight through the proxy.

Non-textual responses (PDFs, fonts, and other file attachments) were
being read with response.text(), which does a lossy UTF-8
decode/re-encode round-trip that corrupts the bytes. The browser then
receives a broken file and can't render it.

Detect the content-type and pass binary bodies straight through; only
HTML/CSS/JS/JSON/XML get rewritten.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@erichurkman

Copy link
Copy Markdown
Author

This was tested in our local notion host. Some PDFs rendered fine, but others didn't. Others rendered some fonts, but not others. This fixed it for all embeds we tested.

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