Say I have an HTTP POST method that simple echos the request's body and I cURL it like so:
curl -X POST -d "test non-binary data" "https://endpoint/path/to/resource"
As expected, this will result in the following callback:
"test non-binary data"
Now let's say I instead pass this data as binary like so:
curl -X POST --data-binary "test binary data" "https://endpoint/path/to/resource"
This will give me the following:
"dGVzdCBiaW5hcnkgZGF0YQ=="
But I can have my API decode the base64 data and interpret it as ASCII to return the following:
"test binary data"
As expected, this is the same as the non-binary request. So, with the results being the same, what exactly is the difference between is passing a binary vs a non-binary request body? Are there any benefits to using binary data? If so, what are some examples when I would want to use binary data instead?
Aucun commentaire:
Enregistrer un commentaire