binary http body: bodyBytes(), Buffer.from base64, serveFile, remove body size limit#94
Merged
binary http body: bodyBytes(), Buffer.from base64, serveFile, remove body size limit#94
Conversation
…ffer.from base64, c.req.bodyBytes()
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
c.req.bodyBytes()returns aUint8Arrayof the raw request body, enabling binary upload handling (images, files, etc.)Uint8Array.fromRawBytes(str, len): new built-in that wraps a raw C string + length into aUint8Arraywithout null-termination assumptionsBuffer.from(str, 'base64'): new base64 decode built-in backed bybase64-bridge.c, returns aUint8ArraybytesResponse(data, status, headers): new codegen primitive that constructs a binaryHttpResponsefrom aUint8Arrayc.bytes(data, contentType): newContextmethod for returning binary responses (implemented in ChadScript on top ofbytesResponse)serveFile(path, contentType): serve a file from disk; imported fromchadscript/http, implemented in ChadScript on top offs.readFileSync+bytesResponselws-bridgenowmallocs exactlyContent-Lengthbytes; large bodies (multi-MB uploads) now receive fullydata_lenafter each chunk so subsequent TCP segments are placed at offset 0 — fixes truncated large-body readsbody_lentype: changed fromint64_ttodoublein the bridge request struct so ChadScript reads it correctly as anumbermethod_call,call, andawaitstatement node types were missing from the closure mutation checker, causing false negativesbase64-bridge.oandtime-bridge.oare now both included in release artifact packaging and vendor verificationTest plan
c.req.bodyBytes()bodyBytes()→Buffer.from(..., 'base64')→ decodeserveFile()serves a static binary file with correctContent-Typec.bytes()returns a binary response with correct headers and body lengthGET /fooandPOST /fooboth match their respective handlersnpm run verifypasses (all unit tests + self-hosting)