diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | THANKS.in | 1 | ||||
-rw-r--r-- | plugins/check_http.c | 20 |
3 files changed, 13 insertions, 9 deletions
@@ -9,6 +9,7 @@ This file documents the major additions and syntax changes between releases. | |||
9 | check_procs now captures stderr in external command and adds to plugin output | 9 | check_procs now captures stderr in external command and adds to plugin output |
10 | check_snmp now only prints perfdata for non numeric values (#1867716) | 10 | check_snmp now only prints perfdata for non numeric values (#1867716) |
11 | check_icmp now supports packet size modification | 11 | check_icmp now supports packet size modification |
12 | check_http now sends the Host header first to fix 301s on servers with vitrual hosts (Michael Harris). | ||
12 | 13 | ||
13 | 1.4.12 27th May 2008 | 14 | 1.4.12 27th May 2008 |
14 | Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren) | 15 | Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren) |
@@ -236,3 +236,4 @@ Jan Wagner | |||
236 | Christian Schneemann | 236 | Christian Schneemann |
237 | Rob Windsor | 237 | Rob Windsor |
238 | Hilko Bengen | 238 | Hilko Bengen |
239 | Michael Harris | ||
diff --git a/plugins/check_http.c b/plugins/check_http.c index 07e0079..f81026f 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -743,21 +743,23 @@ check_http (void) | |||
743 | if (check_cert == TRUE) { | 743 | if (check_cert == TRUE) { |
744 | result = np_net_ssl_check_cert(days_till_exp); | 744 | result = np_net_ssl_check_cert(days_till_exp); |
745 | np_net_ssl_cleanup(); | 745 | np_net_ssl_cleanup(); |
746 | if(sd) close(sd); | 746 | if (sd) close(sd); |
747 | return result; | 747 | return result; |
748 | } | 748 | } |
749 | } | 749 | } |
750 | #endif /* HAVE_SSL */ | 750 | #endif /* HAVE_SSL */ |
751 | 751 | ||
752 | asprintf (&buf, "%s %s HTTP/1.0\r\n%s\r\n", http_method, server_url, user_agent); | 752 | /* If a hostname is provided, use HTTP/1.1 and send the hostname before the |
753 | * Useragent. This fixes an issue with getting 301 responses from servers | ||
754 | * with virtual hosts */ | ||
755 | if (host_name) | ||
756 | asprintf (&buf, "%s %s HTTP/1.1\r\nHost: %s\r\n%s\r\n", http_method, server_url, host_name, user_agent); | ||
757 | else | ||
758 | asprintf (&buf, "%s %s HTTP/1.0\r\n%s\r\n", http_method, server_url, user_agent); | ||
753 | 759 | ||
754 | /* tell HTTP/1.1 servers not to keep the connection alive */ | 760 | /* tell HTTP/1.1 servers not to keep the connection alive */ |
755 | asprintf (&buf, "%sConnection: close\r\n", buf); | 761 | asprintf (&buf, "%sConnection: close\r\n", buf); |
756 | 762 | ||
757 | /* optionally send the host header info */ | ||
758 | if (host_name) | ||
759 | asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); | ||
760 | |||
761 | /* optionally send any other header tag */ | 763 | /* optionally send any other header tag */ |
762 | if (http_opt_headers_count) { | 764 | if (http_opt_headers_count) { |
763 | for (i = 0; i < http_opt_headers_count ; i++) { | 765 | for (i = 0; i < http_opt_headers_count ; i++) { |
@@ -835,7 +837,7 @@ check_http (void) | |||
835 | #ifdef HAVE_SSL | 837 | #ifdef HAVE_SSL |
836 | np_net_ssl_cleanup(); | 838 | np_net_ssl_cleanup(); |
837 | #endif | 839 | #endif |
838 | if(sd) close(sd); | 840 | if (sd) close(sd); |
839 | 841 | ||
840 | /* reset the alarm */ | 842 | /* reset the alarm */ |
841 | alarm (0); | 843 | alarm (0); |
@@ -1101,13 +1103,13 @@ redir (char *pos, char *status_line) | |||
1101 | } | 1103 | } |
1102 | 1104 | ||
1103 | /* URI_HTTP URI_HOST URI_PORT */ | 1105 | /* URI_HTTP URI_HOST URI_PORT */ |
1104 | else if(sscanf (pos, HD3, type, addr, &i) == 3) { | 1106 | else if (sscanf (pos, HD3, type, addr, &i) == 3) { |
1105 | strcpy (url, HTTP_URL); | 1107 | strcpy (url, HTTP_URL); |
1106 | use_ssl = server_type_check (type); | 1108 | use_ssl = server_type_check (type); |
1107 | } | 1109 | } |
1108 | 1110 | ||
1109 | /* URI_HTTP URI_HOST */ | 1111 | /* URI_HTTP URI_HOST */ |
1110 | else if(sscanf (pos, HD4, type, addr) == 2) { | 1112 | else if (sscanf (pos, HD4, type, addr) == 2) { |
1111 | strcpy (url, HTTP_URL); | 1113 | strcpy (url, HTTP_URL); |
1112 | use_ssl = server_type_check (type); | 1114 | use_ssl = server_type_check (type); |
1113 | i = server_port_check (use_ssl); | 1115 | i = server_port_check (use_ssl); |