Skip to content

Use --data-binary instead of --data in curl output #1654

Closed
@jcamiel

Description

Given this file:

POST http://localhost:8000/post_large
Content-Type: application/octet-stream
file,post_large.bin;

Hurl outputs this log:

curl --header 'Content-Type: application/octet-stream' --data '@tests_ok/post_large.bin' 'http://localhost:8000/post_large'

In the curl doc, --data can modify request body when a file is used @foo.bin:

-d, --data

...

If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. Posting data from a file named 'foobar' would thus be done with -d, --data @foobar. When -d, --data is told to read from a file like that, carriage returns and newlines will be stripped out. If you do not want the @ character to have a special interpretation use --data-raw instead.

The data for this option is passed on to the server exactly as provided on the command line. curl will not convert it, change it or improve it. It is up to the user to provide the data in the correct form.
...
--data-binary

(HTTP) This posts data exactly as specified with no extra processing whatsoever.

So if we post a file request body, we should build the curl command with --data-binary

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions