mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-05-16 20:06:57 +02:00
http_request: make http headers available on fd 4
This commit is contained in:
12
dehydrated
12
dehydrated
@@ -450,6 +450,7 @@ _openssl() {
|
|||||||
# Send http(s) request with specified method
|
# Send http(s) request with specified method
|
||||||
http_request() {
|
http_request() {
|
||||||
tempcont="$(_mktemp)"
|
tempcont="$(_mktemp)"
|
||||||
|
tempheaders="$(_mktemp)"
|
||||||
|
|
||||||
if [[ -n "${IP_VERSION:-}" ]]; then
|
if [[ -n "${IP_VERSION:-}" ]]; then
|
||||||
ip_version="-${IP_VERSION}"
|
ip_version="-${IP_VERSION}"
|
||||||
@@ -458,12 +459,13 @@ http_request() {
|
|||||||
set +e
|
set +e
|
||||||
if [[ "${1}" = "head" ]]; then
|
if [[ "${1}" = "head" ]]; then
|
||||||
statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
|
statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
|
||||||
|
touch "${tempheaders}"
|
||||||
curlret="${?}"
|
curlret="${?}"
|
||||||
elif [[ "${1}" = "get" ]]; then
|
elif [[ "${1}" = "get" ]]; then
|
||||||
statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -L -s -w "%{http_code}" -o "${tempcont}" "${2}")"
|
statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -L -s -w "%{http_code}" -o "${tempcont}" -D "${tempheaders}" "${2}")"
|
||||||
curlret="${?}"
|
curlret="${?}"
|
||||||
elif [[ "${1}" = "post" ]]; then
|
elif [[ "${1}" = "post" ]]; then
|
||||||
statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -s -w "%{http_code}" -o "${tempcont}" "${2}" -d "${3}")"
|
statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -s -w "%{http_code}" -o "${tempcont}" "${2}" -D "${tempheaders}" -d "${3}")"
|
||||||
curlret="${?}"
|
curlret="${?}"
|
||||||
else
|
else
|
||||||
set -e
|
set -e
|
||||||
@@ -485,6 +487,7 @@ http_request() {
|
|||||||
echo " + ERROR: An error occurred while sending ${1}-request to ${2} (Status ${statuscode})" >&2
|
echo " + ERROR: An error occurred while sending ${1}-request to ${2} (Status ${statuscode})" >&2
|
||||||
echo >&2
|
echo >&2
|
||||||
echo "Details:" >&2
|
echo "Details:" >&2
|
||||||
|
cat "${tempheaders}" >&2
|
||||||
cat "${tempcont}" >&2
|
cat "${tempcont}" >&2
|
||||||
echo >&2
|
echo >&2
|
||||||
echo >&2
|
echo >&2
|
||||||
@@ -496,6 +499,7 @@ http_request() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "${tempcont}"
|
rm -f "${tempcont}"
|
||||||
|
rm -f "${tempheaders}"
|
||||||
|
|
||||||
# Wait for hook script to clean the challenge if used
|
# Wait for hook script to clean the challenge if used
|
||||||
if [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && [[ -n "${challenge_token:+set}" ]]; then
|
if [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && [[ -n "${challenge_token:+set}" ]]; then
|
||||||
@@ -508,8 +512,12 @@ http_request() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if { true >&4; } 2>/dev/null; then
|
||||||
|
cat "${tempheaders}" >&4
|
||||||
|
fi
|
||||||
cat "${tempcont}"
|
cat "${tempcont}"
|
||||||
rm -f "${tempcont}"
|
rm -f "${tempcont}"
|
||||||
|
rm -f "${tempheaders}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send signed request
|
# Send signed request
|
||||||
|
|||||||
Reference in New Issue
Block a user