Repository navigation
Conversation
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.
Summary
Fixes #157.
In
/proxy, requests were previously read usingawait req.clone().text(), which converts raw request bytes to a UTF-8 string. When proxying binary payloads (such as octet-streams, images, or compressed data), invalid UTF-8 sequences were corrupted during string decoding. Furthermore, request bodies were only read forPOST,PUT, andPATCH, completely dropping bodies forDELETEandOPTIONSrequests despite the route accepting those methods.Changes
routes/proxy.ts):.text()toawait req.clone().arrayBuffer().GETandHEAD(forwardingDELETEandOPTIONSbodies as well).tests/routes/proxy-binary-body.test.ts):POST,PUT,PATCH,DELETE, andOPTIONSagainst a local upstream server using invalid UTF-8 byte sequences ([0x00, 0xff, 0xfe, 0x80, 0x41]).Validation
bun test: 34 passed, 0 failed across 10 files (180 assertions).bun x tsc --noEmit: 0 type errors.bun x @biomejs/biome format: verified clean.