diff options
author | Rasp8e <bogdan.balamat@ext.ec.europa.eu> | 2017-10-17 13:19:43 (GMT) |
---|---|---|
committer | Rasp8e <bogdan.balamat@ext.ec.europa.eu> | 2017-10-17 13:19:43 (GMT) |
commit | 09a2210c477932c8df40ff820414b3a9bbec10fb (patch) | |
tree | bdca5f724222dd96268bfe4a48de6ac0136ce3fe /plugins/check_http.c | |
parent | 9661ee74885834f7b69ab0874c4e65bed0b871c9 (diff) | |
download | monitoring-plugins-09a2210c477932c8df40ff820414b3a9bbec10fb.tar.gz |
Adding Proxy-Authorization and extra headers in the case of connection through PROXY to HTTPSrefs/pull/1514/head
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r-- | plugins/check_http.c | 15 |
1 files changed, 15 insertions, 0 deletions
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) | |||
916 | 916 | ||
917 | if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); | 917 | if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); |
918 | asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); | 918 | asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); |
919 | if (strlen(proxy_auth)) { | ||
920 | base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth); | ||
921 | xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth); | ||
922 | } | ||
923 | /* optionally send any other header tag */ | ||
924 | if (http_opt_headers_count) { | ||
925 | for (i = 0; i < http_opt_headers_count ; i++) { | ||
926 | if (force_host_header != http_opt_headers[i]) { | ||
927 | xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]); | ||
928 | } | ||
929 | } | ||
930 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ | ||
931 | /* Covered in a testcase in tests/check_http.t */ | ||
932 | /* free(http_opt_headers); */ | ||
933 | } | ||
919 | asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf); | 934 | asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf); |
920 | asprintf (&buf, "%sHost: %s\r\n", buf, host_name); | 935 | asprintf (&buf, "%sHost: %s\r\n", buf, host_name); |
921 | /* we finished our request, send empty line with CRLF */ | 936 | /* we finished our request, send empty line with CRLF */ |