Binary Request Bodies
Source file: examples/binary_request_body.hen
What It Demonstrates
body_file = @pathfor raw file-backed request bodies- explicit
Content-Typeheaders for binary uploads - assertions against the echoed Buffer-shaped payload returned by Postman Echo
Key Pattern
POST https://postman-echo.com/post
body_file = @./files/raw_payload.bin
* Content-Type = application/octet-stream
^ & status == 200
^ & body.headers.content-type == 'application/octet-stream'
^ & body.data.type == 'Buffer'
^ & body.data.data[0] == 114
^ & body.data.data[1] == 97
^ & body.data.data[2] == 119
^ & body.data.data[27] == 49
Run It
hen verify ./examples/binary_request_body.hen
hen run ./examples/binary_request_body.hen all --non-interactive
What To Notice
- Hen reads the outbound body directly from disk instead of an inline
~~~block. body_filepaths are resolved relative to the collection file.- The request body is sent as raw bytes, which matches
curl --data-binary @filesemantics. - Postman Echo reports an
application/octet-streampayload as a JSONBufferobject, so the assertions inspect the returned byte array instead of a plain string body. - File-backed bodies are only valid for ordinary HTTP requests.
Related reference: Requests and bodies