4

I recently used curl's --data option to upload some JSON to a server, and after reading the manpage, I'm not sure whether I can have faith that it got there intact.

curl's manpage explicitly describes one difference between curl's --data/--data-ascii and --data-binary options; namely, that when the @filename syntax is used to make curl read data from a file, --data will strip newlines from the file but --data-binary will not.

However, the man page also makes it sound like there are more differences. The following passage from the description of --data-binary can only be reasonably interpreted to mean that there are certain 'conversions' besides newline removal that --data does on the data it is given:

--data-binary <data>

...

... Data is posted in a similar manner as --data-ascii does, except that newlines and carriage returns are preserved and conversions are never done. (emphasis mine)

What are these mysterious "conversions"? Do they even exist? They are not documented in the manual's section on the --data option, nor can I discover them through experimentation. The obvious things that one might expect the --data option to transform (like ampersands, slashes, hashes, question marks, equals signs, Chinese characters, or grinning cat faces with smiling eyes) all get sent intact and unchanged.

So what is the manual talking about?

1

What are these mysterious "conversions"?

Without the binary flag stdin is read in text mode (this makes a difference on Windows), and, on platforms that need it (IBM mainframes and the like), data is re-encoded from charset IBM-1047 (a.k.a. EBCDIC) to ISO8859-1 using iconv(3). There is also a difference in the way data length (as passed to Content-Length and friends) is computed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.