Skip to content
Snippets Groups Projects
Commit 566ebd14 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

added debugging of curl request

parent be17403f
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2021-03-31 v1.0 <axel.hahn@iml.unibe.ch> init # 2021-03-31 v1.0 <axel.hahn@iml.unibe.ch> init
# 2021-04-13 v1.1 <axel.hahn@iml.unibe.ch> add support for custom config # 2021-04-13 v1.1 <axel.hahn@iml.unibe.ch> add support for custom config
# 2021-04-15 v1.2 <axel.hahn@iml.unibe.ch> added debugging of curl request
# ====================================================================== # ======================================================================
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -125,27 +126,39 @@ ${apiTS} ...@@ -125,27 +126,39 @@ ${apiTS}
myHash=`echo -n "$data" | openssl sha1 -hmac "${secret}" | cut -f 2 -d" "` myHash=`echo -n "$data" | openssl sha1 -hmac "${secret}" | cut -f 2 -d" "`
myHash=`echo -n "$myHash" | base64` myHash=`echo -n "$myHash" | base64`
moreheaders="--fail"
test $bDebug = 1 && moreheaders="-i"
tmpdownloadfile="${outfile}.downloading"
curl \ curl \
-H "Accept: application/json" -H "Content-Type: application/json" \ -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Date: ${apiTS}" \ -H "Date: ${apiTS}" \
-H "Authorization: demo-bash-client:${myHash}" \ -H "Authorization: demo-bash-client:${myHash}" \
-X $apiMethod \ -X $apiMethod \
-o "${outfile}.downloading" \ -o "${tmpdownloadfile}" \
--fail \ $moreheaders \
-s \ -s \
${IMLCI_URL}${apiRequest} ${IMLCI_URL}${apiRequest}
if [ $? -eq 0 ]; then rc=$?
if [ "$bDebug" = "1" ]; then
cat "${tmpdownloadfile}"
rm -f "${tmpdownloadfile}"
exit 0
fi
if [ $rc -eq 0 ]; then
# echo OK. # echo OK.
# no outfile (= request to a directory) # no outfile (= request to a directory)
if [ -z "$outfile" ]; then if [ -z "$outfile" ]; then
# echo # echo
# echo ----- RESPONSE BODY: # echo ----- RESPONSE BODY:
cat "${outfile}.downloading" cat "${tmpdownloadfile}"
rm -f "${outfile}.downloading" rm -f "${tmpdownloadfile}"
else else
mv "${outfile}.downloading" "${outfile}" mv "${tmpdownloadfile}" "${outfile}"
ls -l "${outfile}" ls -l "${outfile}"
fi fi
else else
...@@ -155,7 +168,7 @@ ${apiTS} ...@@ -155,7 +168,7 @@ ${apiTS}
curl\ curl\
-H "Accept: application/json" -H "Content-Type: application/json" \ -H "Accept: application/json" -H "Content-Type: application/json" \
-X $apiMethod \ -X $apiMethod \
-o "${outfile}.downloading" \ -o "${tmpdownloadfile}" \
${IMLCI_URL}${apiRequest} ${IMLCI_URL}${apiRequest}
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment