|
// 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
|