cURL: Read from File or Stdin
Redirect or pipe the content of a file or the output of another command as the input of cURL, for example, making a POST request with cURL.
This is done by prefixing the data parameter with @, the rest is the filename to read data from. With -, the data is coming from stdin:
|
|
Command seq 17000 1 17001 returns:
|
|
The size of the above two numbers is 12 bytes (including two newlines). But when reading data via @ with --data option, “carriage returns and newlines will be stripped out” [1]. If you check your server, you will see the content length is only 10 bytes.
To correct this problem, we will send the raw data using --data-binary option instead. This preserves \n and \r characters.