mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-04-18 22:49:47 +02:00
trying to capture http status codes from curl instead of using "--fail" to be able to capture acme error messages
This commit is contained in:
@@ -51,22 +51,27 @@ hex2bin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_request() {
|
_request() {
|
||||||
temperr="$(mktemp)"
|
tempcont="$(mktemp)"
|
||||||
|
|
||||||
if [[ "${1}" = "head" ]]; then
|
if [[ "${1}" = "head" ]]; then
|
||||||
curl -sSf -I "${2}" 2> "${temperr}"
|
statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
|
||||||
elif [[ "${1}" = "get" ]]; then
|
elif [[ "${1}" = "get" ]]; then
|
||||||
curl -sSf "${2}" 2> "${temperr}"
|
statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}")"
|
||||||
elif [[ "${1}" = "post" ]]; then
|
elif [[ "${1}" = "post" ]]; then
|
||||||
curl -sSf "${2}" -d "${3}" 2> "${temperr}"
|
statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}" -d "${3}")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -s "${temperr}" ]]; then
|
if [[ ! "${statuscode:0:1}" = "2" ]]; then
|
||||||
echo " + ERROR: An error occured while sending ${1}-request to ${2} ($(<"${temperr}"))" >&2
|
echo " + ERROR: An error occured while sending ${1}-request to ${2} (Status ${statuscode})" >&2
|
||||||
rm -f "${temperr}"
|
echo >&2
|
||||||
|
echo "Details:" >&2
|
||||||
|
echo "$(<"${tempcont}"))" >&2
|
||||||
|
rm -f "${tempcont}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "${temperr}"
|
cat "${tempcont}"
|
||||||
|
rm -f "${tempcont}"
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_request() {
|
signed_request() {
|
||||||
|
|||||||
Reference in New Issue
Block a user