mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-07-08 14:05:25 +02:00
return error on invalid request method in http_request, shortened http_request a bit
This commit is contained in:
+5
-5
@@ -165,6 +165,7 @@ _openssl() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Send http(s) request with specified method
|
||||||
http_request() {
|
http_request() {
|
||||||
tempcont="$(mktemp)"
|
tempcont="$(mktemp)"
|
||||||
|
|
||||||
@@ -174,6 +175,8 @@ http_request() {
|
|||||||
statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}")"
|
statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}")"
|
||||||
elif [[ "${1}" = "post" ]]; then
|
elif [[ "${1}" = "post" ]]; then
|
||||||
statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}" -d "${3}")"
|
statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}" -d "${3}")"
|
||||||
|
else
|
||||||
|
_exiterr "Unknown request method: ${1}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! "${statuscode:0:1}" = "2" ]]; then
|
if [[ ! "${statuscode:0:1}" = "2" ]]; then
|
||||||
@@ -184,15 +187,12 @@ http_request() {
|
|||||||
rm -f "${tempcont}"
|
rm -f "${tempcont}"
|
||||||
|
|
||||||
# Wait for hook script to clean the challenge if used
|
# Wait for hook script to clean the challenge if used
|
||||||
if [[ -n "${HOOK}" ]] && [[ -n "${challenge_token:+set}" ]]; then
|
if [[ -n "${HOOK}" ]] && [[ -n "${challenge_token:+set}" ]]; then
|
||||||
${HOOK} "clean_challenge" '' "${challenge_token}" "${keyauth}"
|
${HOOK} "clean_challenge" '' "${challenge_token}" "${keyauth}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove temporary domains.txt file if used
|
# remove temporary domains.txt file if used
|
||||||
if [[ -n "${PARAM_DOMAIN:-}" ]]; then
|
[[ -n "${PARAM_DOMAIN:-}" ]] && rm "${DOMAINS_TXT}"
|
||||||
rm "${DOMAINS_TXT}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user