Add status check
This commit is contained in:
parent
27361645cd
commit
d94d7e71a1
17
laconia
17
laconia
|
@ -13,7 +13,21 @@ usage() {
|
|||
}
|
||||
|
||||
request(){
|
||||
printf "$host /$path $( $post | wc -c )\r\n$post" | nc $host $port
|
||||
page=$(printf "$host /$path $( $post | wc -c )\r\n$post" | nc $host $port)
|
||||
status=$(echo $page | awk 'NR == 1 {print $1}')
|
||||
meta=$(echo $page | awk 'NR == 1 {print $2}')
|
||||
if [[ $status == 2 ]]; then
|
||||
printf "$host /$path $( $post | wc -c )\r\n$post" | nc $host $port
|
||||
elif [[ $status == 3 ]]; then
|
||||
path=$meta
|
||||
printf "$host $path 0\r\n" | nc $host 300
|
||||
echo $host $path
|
||||
elif [[ $status == 4 ]]; then
|
||||
printf "Client error: %s\n" "$meta"
|
||||
elif [[ $status == 5 ]]; then
|
||||
printf "$host /$path $( $post | wc -c )\r\n$post" | nc $host $port
|
||||
#printf "Server error: %s\n" "$meta"
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":h:p:i:u:" arg; do
|
||||
|
@ -35,7 +49,6 @@ while getopts ":h:p:i:u:" arg; do
|
|||
host=$(echo "$url" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
|
||||
path="$(echo $url | grep / | cut -d/ -f2-)"
|
||||
port=${port:-300}
|
||||
echo $port $post $host $path
|
||||
request
|
||||
else
|
||||
echo $url_unparsed is not a Spartan URL
|
||||
|
|
Loading…
Reference in New Issue