Files
wren/test/web/multipart_binary.wren
T
retoor 38de4da87d feat: add bytes.indexOf, server.acceptBatch, server.pendingCount, stdin data callback, and coverage/valgrind make targets
Implement `bytesIndexOf` foreign function supporting optional start offset for searching byte sequences. Add `serverAcceptBatch` and `serverPendingCount` to net module for batch accepting connections and querying pending queue size. Refactor `stdinFileTimerCallback` to pass read bytes to Wren callback instead of null, with separate handling for EOF. Introduce `coverage_64bit` build config with gcov flags, plus `coverage`, `valgrind`, `clean-coverage`, and `publish` phony targets in Makefile. Fix memory leak in regex by nullifying freed pointers on allocation failure.
2026-01-26 11:29:25 +00:00

21 lines
795 B
JavaScript
Vendored

// retoor <retoor@molodetz.nl>
import "web" for Request
var binaryContent = String.fromByte(0) + String.fromByte(255) + String.fromByte(127)
var body = "------boundary\r\n" +
"Content-Disposition: form-data; name=\"data\"; filename=\"binary.dat\"\r\n" +
"Content-Type: application/octet-stream\r\n" +
"\r\n" +
binaryContent + "\r\n" +
"------boundary--\r\n"
var headers = {"Content-Type": "multipart/form-data; boundary=----boundary"}
var request = Request.new_("POST", "/upload", {}, headers, body, {}, null)
var form = request.form
System.print(form["data"]["content"].bytes.count) // expect: 3
System.print(form["data"]["content"].bytes[0]) // expect: 0
System.print(form["data"]["content"].bytes[1]) // expect: 255
System.print(form["data"]["content"].bytes[2]) // expect: 127