@@ -80,21 +80,21 @@ api_factory() {
8080}
8181
8282display_results () {
83- local res=$( jq -r ' .http_status + " " + .http_message ' <<< " $HEADER " )
84- local status=$( jq -r ' .http_status' <<< " $HEADER " )
83+ local res=$( jq -r ' .http_status + " " + .http_message ' <<< " $RESPONSE_HEADER " )
84+ local status=$( jq -r ' .http_status' <<< " $RESPONSE_HEADER " )
8585 echo " Response:"
8686 echo " ${BOLD} $( color_response $status ) $res ${RESET} "
8787 if [[ $HEADER_ONLY == 1 ]]; then
8888 echo " HEADER:"
89- echo " $HEADER " | jq -C
89+ echo " $RESPONSE_HEADER " | jq -C
9090 else
9191 if [[ $SHOW_HEADER == 1 ]]; then
9292 echo " HEADER:"
93- echo " $HEADER " | jq -C
93+ echo " $RESPONSE_HEADER " | jq -C
9494 fi
9595 if [[ $SILENT == 0 ]]; then
9696 echo " BODY:"
97- echo " $BODY " | jq -C
97+ echo " $RESPONSE_BODY " | jq -C
9898 fi
9999
100100 fi
@@ -135,7 +135,7 @@ call_api() {
135135 fi
136136 local header=" $( awk -v bl=1 ' bl{bl=0; h=($0 ~ /HTTP\//)} /^\r?$/{bl=1} {if(h)print $0 }' <<< " $raw_output" ) "
137137 local json=$( jq -c -R -r ' . as $line | try fromjson' <<< " $raw_output" )
138- BODY =$( sed -n 1p <<< " $json" )
138+ RESPONSE_BODY =$( sed -n 1p <<< " $json" )
139139 META=$( sed 1d <<< " $json" )
140140 META=$( jq -r " .Size = \" $( bytes_to_human $( jq -r ' .Size' <<< " $META" ) ) \" " <<< " $META" )
141141 parse_header " $header "
@@ -144,7 +144,7 @@ call_api() {
144144function parse_header() {
145145 local RESPONSE=($( echo " $header " | tr ' \r' ' ' | sed -n 1p) )
146146 local header=$( echo " $header " | sed ' 1d;$d' | sed ' s/: /" : "/' | sed ' s/^/"/' | tr ' \r' ' ' | sed ' s/ $/",/' | sed ' 1 s/^/{/' | sed ' $ s/,$/}/' | jq)
147- HEADER =$( echo " $header " " { \" http_version\" : \" ${RESPONSE[0]} \" ,
147+ RESPONSE_HEADER =$( echo " $header " " { \" http_version\" : \" ${RESPONSE[0]} \" ,
148148 \" http_status\" : \" ${RESPONSE[1]} \" ,
149149 \" http_message\" : \" ${RESPONSE[@]: 2} \" ,
150150 \" http_response\" : \" ${RESPONSE[@]: 0} \" }" | jq -s add)
0 commit comments