Skip to content

Instantly share code, notes, and snippets.

@composite
Last active August 8, 2019 05:28
Show Gist options
  • Select an option

  • Save composite/e3579db71ea6da9485745a1fbe7301d6 to your computer and use it in GitHub Desktop.

Select an option

Save composite/e3579db71ea6da9485745a1fbe7301d6 to your computer and use it in GitHub Desktop.
file content as post parameter value example (split by backslash for getting multiple request)
#!/bin/bash
function post() {
mkdir -p "$HOME/tmp/"
local a="$HOME/tmp/Q_$(openssl rand -hex 16).req"
echo > "$a"
vi "$a"
local b=""
local c=""
local t=""
local n=$(printf '\n')
local e=$(printf '\\')
local x="\\\\+"
while read -r r; do
t=$(echo "$r" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
[ -z "$t" ] && continue
if [[ "$t" =~ $x && ! -z "$c" ]]; then
b=$(echo "$c" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"+"')
c=""
wget -q -O- --post-data="data=$b" "http://localhost:8080/post/data"
elif [ ! -z "$t" ]; then
c="$c $t$n"
fi
done < "$a"
if [ ! -z "$c" ]; then
b=$(echo "$c" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"+"')
wget -q -O- --post-data="data=$b" "http://localhost:8080/post/data"
fi
rm -f "$a"
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment