[monitoring-plugins] setting no_body to TRUE when we have a HEAD ...

Andreas Baumann git at monitoring-plugins.org
Fri Oct 11 17:30:11 CEST 2019


 Module: monitoring-plugins
 Branch: feature_check_curl
 Commit: ede43c848d5ea8cb1d7fb23af1d638e6fff9aa41
 Author: Andreas Baumann <mail at andreasbaumann.cc>
   Date: Fri Oct 11 17:22:34 2019 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ede43c8

setting no_body to TRUE when we have a HEAD request

---

 plugins/check_curl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 9dea9c4..69b6344 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -387,6 +387,11 @@ check_http (void)
     http_method = "GET";
     handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_URL, server_url), "CURLOPT_URL");
   }
+
+  /* disable body for HEAD request */
+  if (http_method && !strcmp (http_method, "HEAD" )) {
+    no_body = TRUE;
+  }
   
   /* set HTTP protocol version */
   handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HTTP_VERSION, curl_http_version), "CURLOPT_HTTP_VERSION");
@@ -627,7 +632,7 @@ check_http (void)
       server_port, res, curl_easy_strerror(res));
     die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
   }
-
+  
   /* certificate checks */
 #ifdef LIBCURL_FEATURE_SSL
   if (use_ssl == TRUE) {



More information about the Commits mailing list