You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently users can read a binary file or receive a binary HTTP response and send that as an HTTP request body:
import{sleep}from"k6";importhttpfrom"k6/http";importcryptofrom"k6/crypto";// Manually downloaded from https://httpbin.org/image/pngvarbinaryFile=open("./image.png","b");exportdefaultfunction(data){letbinaryResp=http.get("https://httpbin.org/image/png",{responseType: "binary"});console.log(crypto.sha256(binaryFile,"hex"));console.log(crypto.sha256(binaryResp.body,"hex"));console.log("Lengths: ",binaryFile.length,binaryResp.body.length);letresp=http.post("https://httpbin.org/anything",binaryResp.body);console.log(resp.body);}
They can even modify those binary arrays without extending them (so binaryFile[100] = 123; will work, but binaryFile[10000] = 123; won't). But they cannot construct a new binary buffer from scratch. Normal JS arrays won't (and probably shouldn't) work, and JS strings are unsuitable for a lot of tasks, since they're UTF-16 encoded. Ideally, once we fix this issue, we can use typed arrays for sending arbitrary binary payloads as HTTP request bodies.
The text was updated successfully, but these errors were encountered:
This was fixed by #1776, which allowed users to pass ArrayBuffer values as the request body. Everything else that's binary-related is tracked by #1020 and has a WIP PR already (#1800).
Currently users can read a binary file or receive a binary HTTP response and send that as an HTTP request body:
They can even modify those binary arrays without extending them (so
binaryFile[100] = 123;
will work, butbinaryFile[10000] = 123;
won't). But they cannot construct a new binary buffer from scratch. Normal JS arrays won't (and probably shouldn't) work, and JS strings are unsuitable for a lot of tasks, since they're UTF-16 encoded. Ideally, once we fix this issue, we can use typed arrays for sending arbitrary binary payloads as HTTP request bodies.The text was updated successfully, but these errors were encountered: