summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2367f82)
raw | patch | inline | side by side (parent: 2367f82)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 8 Aug 2008 02:25:47 +0000 (02:25 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 8 Aug 2008 02:25:47 +0000 (02:25 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2030 f882894a-f735-0410-b71e-b25c423dba1c
NEWS | patch | blob | history | |
THANKS.in | patch | blob | history | |
plugins/check_http.c | patch | blob | history |
index 2e33951b66610bef3397ea4f3d5039dff2f430d7..168aee5e065b9948a8d499fb36986a3e99ce2ebd 100644 (file)
--- a/NEWS
+++ b/NEWS
check_procs now captures stderr in external command and adds to plugin output
check_snmp now only prints perfdata for non numeric values (#1867716)
check_icmp now supports packet size modification
+ check_http now sends the Host header first to fix 301s on servers with vitrual hosts (Michael Harris).
1.4.12 27th May 2008
Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren)
diff --git a/THANKS.in b/THANKS.in
index 718d0f320048424983ef6851162606d844332ac2..b9a496157deee14fd4261fb0dd9097ce24341eae 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
Christian Schneemann
Rob Windsor
Hilko Bengen
+Michael Harris
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 07e0079e64b6035fae062004ec9044d6881c1f66..f81026f8d0ef4995efc8cb1118e8b15bcb542b34 100644 (file)
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
if (check_cert == TRUE) {
result = np_net_ssl_check_cert(days_till_exp);
np_net_ssl_cleanup();
- if(sd) close(sd);
+ if (sd) close(sd);
return result;
}
}
#endif /* HAVE_SSL */
- asprintf (&buf, "%s %s HTTP/1.0\r\n%s\r\n", http_method, server_url, user_agent);
+ /* If a hostname is provided, use HTTP/1.1 and send the hostname before the
+ * Useragent. This fixes an issue with getting 301 responses from servers
+ * with virtual hosts */
+ if (host_name)
+ asprintf (&buf, "%s %s HTTP/1.1\r\nHost: %s\r\n%s\r\n", http_method, server_url, host_name, user_agent);
+ else
+ asprintf (&buf, "%s %s HTTP/1.0\r\n%s\r\n", http_method, server_url, user_agent);
/* tell HTTP/1.1 servers not to keep the connection alive */
asprintf (&buf, "%sConnection: close\r\n", buf);
- /* optionally send the host header info */
- if (host_name)
- asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
-
/* optionally send any other header tag */
if (http_opt_headers_count) {
for (i = 0; i < http_opt_headers_count ; i++) {
#ifdef HAVE_SSL
np_net_ssl_cleanup();
#endif
- if(sd) close(sd);
+ if (sd) close(sd);
/* reset the alarm */
alarm (0);
}
/* URI_HTTP URI_HOST URI_PORT */
- else if(sscanf (pos, HD3, type, addr, &i) == 3) {
+ else if (sscanf (pos, HD3, type, addr, &i) == 3) {
strcpy (url, HTTP_URL);
use_ssl = server_type_check (type);
}
/* URI_HTTP URI_HOST */
- else if(sscanf (pos, HD4, type, addr) == 2) {
+ else if (sscanf (pos, HD4, type, addr) == 2) {
strcpy (url, HTTP_URL);
use_ssl = server_type_check (type);
i = server_port_check (use_ssl);