]> git.street.me.uk Git - andy/dehydrated.git/commitdiff
return error on invalid request method in http_request, shortened http_request a bit
authorLukas Schauer <lukas@schauer.so>
Fri, 8 Jan 2016 18:35:55 +0000 (19:35 +0100)
committerLukas Schauer <lukas@schauer.so>
Fri, 8 Jan 2016 19:00:30 +0000 (20:00 +0100)
letsencrypt.sh

index 30f01ec8c748158de0d02237c5e81740d80f6eaa..d9405012d6ef5f900d4852f9b6ce5f2088f6fa94 100755 (executable)
@@ -165,6 +165,7 @@ _openssl() {
   fi
 }
 
+# Send http(s) request with specified method
 http_request() {
   tempcont="$(mktemp)"
 
@@ -174,6 +175,8 @@ http_request() {
     statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}")"
   elif [[ "${1}" = "post" ]]; then
     statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}" -d "${3}")"
+  else
+    _exiterr "Unknown request method: ${1}"
   fi
 
   if [[ ! "${statuscode:0:1}" = "2" ]]; then
@@ -184,15 +187,12 @@ http_request() {
     rm -f "${tempcont}"
 
     # 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}"
     fi
 
     # remove temporary domains.txt file if used
-    if [[ -n "${PARAM_DOMAIN:-}" ]]; then
-      rm "${DOMAINS_TXT}"
-    fi
-
+    [[ -n "${PARAM_DOMAIN:-}" ]] && rm "${DOMAINS_TXT}"
     exit 1
   fi