[monitoring-plugins] Adding Proxy-Authorization and extra headers in ...

Rasp8e git at monitoring-plugins.org
Wed Sep 23 17:20:10 CEST 2020


 Module: monitoring-plugins
 Branch: master
 Commit: 09a2210c477932c8df40ff820414b3a9bbec10fb
 Author: Rasp8e <bogdan.balamat at ext.ec.europa.eu>
   Date: Tue Oct 17 15:19:43 2017 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=09a2210

Adding Proxy-Authorization and extra headers in the case of connection through PROXY to HTTPS

---

 plugins/check_http.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/plugins/check_http.c b/plugins/check_http.c
index 86a36c2..2e393eb 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -916,6 +916,21 @@ check_http (void)
 
     if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT);
     asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent);
+    if (strlen(proxy_auth)) {
+      base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth);
+      xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth);
+    }
+    /* optionally send any other header tag */
+    if (http_opt_headers_count) {
+      for (i = 0; i < http_opt_headers_count ; i++) {
+        if (force_host_header != http_opt_headers[i]) {
+          xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]);
+        }
+      }
+      /* This cannot be free'd here because a redirection will then try to access this and segfault */
+      /* Covered in a testcase in tests/check_http.t */
+      /* free(http_opt_headers); */
+    }
     asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf);
     asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
     /* we finished our request, send empty line with CRLF */



More information about the Commits mailing list