Skip to content

Instantly share code, notes, and snippets.

@vbarbarosh
Last active May 15, 2019 18:32
Show Gist options
  • Save vbarbarosh/2dd5a75d4538644e7953c61990500725 to your computer and use it in GitHub Desktop.
Save vbarbarosh/2dd5a75d4538644e7953c61990500725 to your computer and use it in GitHub Desktop.
shell_curl_post_urlencoded_unsafe – POST as application/x-www-form-urlencoded with curl https://codescreens.com
#!/bin/bash
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o nounset -o errexit -o pipefail
# POST as application/x-www-form-urlencoded with curl
# https://curl.haxx.se/docs/manpage.html
# No encoding will be made at all. If contents are taken from a file
# then all lines will be joined into one long line with crlf replaced
# with space. Several -d parameters will be merged with & symbol to
# form entire POST body.
curl -sf https://echo.vbarbarosh.com \
-d 'just a binary string ~!@#$%^&*(_+)' \
-d @filename_strip_crlf.txt
# No encoding will be made at all. Several --data-binary will be
# merged with & symbol to form entire POST body.
curl -sf https://echo.vbarbarosh.com \
--data-binary 'just a binary string ~!@#$%^&*(_+)' \
--data-binary @filename_binary.txt
# No encoding will be made at all, @ at the beginning
# has no special meaning. Several --data-raw will be merged with &
# symbol to form entire POST body.
curl -sf https://echo.vbarbarosh.com \
--data-raw 'just a binary string ~!@#$%^&*(_+)' \
--data-raw '@another xxxxxxxxbinary string ~!@#$%^&*(_+)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment