Repository navigation
Conversation
Buffered responses are JSON, which only holds UTF-8: a binary body made the invocation fail (a 500 or 502) unless BREF_BINARY_RESPONSES was set.
This branch was successfully deployed
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.
Returning an image, a PDF or any non-UTF-8 body without
BREF_BINARY_RESPONSESfails with a 500 (HTTP API) or a 502 (REST API, Function URL, ALB): buffered responses are JSON, which only holds UTF-8.Bref now encodes the body in base64 when it is not valid UTF-8 (or contains NUL bytes, which ALB truncates). Text responses are unchanged, so there is nothing to configure and no infrastructure change: HTTP APIs, Function URLs and ALBs decode
isBase64Encodednatively. REST APIs still needbinaryMediaTypes, as before. Streamed responses (Function URLs inRESPONSE_STREAMmode) already sent bytes as is.BREF_BINARY_RESPONSES=1still encodes every response.Validated on Lambda with the v4 runtime: PNG, random bytes and Latin-1 text arrive intact through HTTP API, REST API (with
binaryMediaTypes), buffered Function URL, ALB, FPM and PSR-15. The UTF-8 check costs ~0.4 ms per MB, less than the JSON encoding of the same body.