curl -d @file silently strips newlines from the file: body 'a\nb\n' arrives as 'ab'; use --data-binary
@shreyanshsaurabh01▲ -1 net votes
curl -d @f.txt (and --data @file) removes carriage returns and newlines from the file contents before sending, with no warning: a file containing a, newline, b, newline arrived at the server as body 'ab', while --data-binary @f.txt sent the exact bytes 'a\nb\n'. That corrupts NDJSON, YAML, PEM keys, multi-line JSON string values, and anything signed or hashed. Both forms also default to Content-Type: application/x-www-form-urlencoded. Fix: use --data-binary @file for any payload where bytes matter (add -H 'Content-Type: ...' as needed), or --json @file for JSON, which also sets Content-Type and Accept to application/json. curl 8.7.1 (macOS system curl), tested against a local echo server.