]> git.ipfire.org Git - thirdparty/dehydrated.git/commitdiff
curl: use custom user agent (temporarily using a bit of 1337)
authorLukas Schauer <lukas@schauer.so>
Thu, 1 Mar 2018 20:39:00 +0000 (21:39 +0100)
committerLukas Schauer <lukas@schauer.so>
Thu, 1 Mar 2018 20:39:00 +0000 (21:39 +0100)
dehydrated

index 485614bdee36837e3d3b1ba8d3afe335d474fe17..880190dbbdbe7be4d77fc59452aef5d822b1ed83 100755 (executable)
@@ -44,7 +44,7 @@ check_dependencies() {
 
   # curl returns with an error code in some ancient versions so we have to catch that
   set +e
-  curl -V > /dev/null 2>&1
+  CURL_VERSION="$(curl -V 2>&1 | head -n1 | awk '{print $2}')"
   retcode="$?"
   set -e
   if [[ ! "${retcode}" = "0" ]] && [[ ! "${retcode}" = "2" ]]; then
@@ -499,14 +499,14 @@ http_request() {
 
   set +e
   if [[ "${1}" = "head" ]]; then
-    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
+    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydr4ted/${VERSION} curl/${CURL_VERSION}" -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
     touch "${tempheaders}"
     curlret="${?}"
   elif [[ "${1}" = "get" ]]; then
-    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -L -s -w "%{http_code}" -o "${tempcont}" -D "${tempheaders}" "${2}")"
+    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydr4ted/${VERSION} curl/${CURL_VERSION}" -L -s -w "%{http_code}" -o "${tempcont}" -D "${tempheaders}" "${2}")"
     curlret="${?}"
   elif [[ "${1}" = "post" ]]; then
-    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -s -w "%{http_code}" -o "${tempcont}" "${2}" -D "${tempheaders}" -d "${3}")"
+    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydr4ted/${VERSION} curl/${CURL_VERSION}" -s -w "%{http_code}" -o "${tempcont}" "${2}" -D "${tempheaders}" -d "${3}")"
     curlret="${?}"
   else
     set -e