jeudi 29 août 2019

Which conversions are made by `curl --data

I've read man curl, but I'm still not sure of the semantics of curl --data <data>.

From the description of --data, it seems like this option causes Curl to send an HTTP POST request, using the Content-Type application/x-www-form-urlencoded, with the specified <data> (and nothing more).

However, reading the description of --data-binary, it says, compared to --data, that newlines are preserved and conversions are never done.

So, is --data removing all newlines, and what conversions will it make? Why isn't this mentioned in the description of --data?

Excerpt of man curl:

 --data-binary <data>
              (HTTP) This posts data exactly as specified with no extra processing whatsoever.

              If you start the data with the letter @, the rest should be a filename.  Data is posted in a similar manner as --data-ascii does, except that newlines are preserved and conversions are  never
              done.

 -d, --data <data>
              (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause
              curl to pass the data to the server using the content-type application/x-www-form-urlencoded.  Compare to -F, --form.

              -d, --data is the same as --data-ascii. To post data purely binary, you should instead use the --data-binary option. To URL-encode the value of a form field you may use --data-urlencode.




Aucun commentaire:

Enregistrer un commentaire