From ae251d3e02823395b5457574781ea95f492d71ed Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Sat, 23 Aug 2008 14:20:27 +0000 Subject: [PATCH] add support for virtual servers --- debian/changelog | 2 ++ .../41_check_http_fix_http_header.dpatch | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 debian/patches/41_check_http_fix_http_header.dpatch diff --git a/debian/changelog b/debian/changelog index 8970726..2d1eec8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ nagios-plugins (1.4.12-3) UNRELEASED; urgency=low * rename 40_check_http_status_line.patch to 40_check_http_status_line.dpatch and make it able to apply * add 40_check_http_status_line.dpatch to 00list to really fix #486932 + * add 41_check_http_fix_http_header.dpatch to support virtual servers + (Closes: #494835) -- Jan Wagner Fri, 04 Jul 2008 17:04:02 +0200 diff --git a/debian/patches/41_check_http_fix_http_header.dpatch b/debian/patches/41_check_http_fix_http_header.dpatch new file mode 100755 index 0000000..5cacd50 --- /dev/null +++ b/debian/patches/41_check_http_fix_http_header.dpatch @@ -0,0 +1,33 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 41_check_http_fix_http_header.dpatch by Jan Wagner , taken +## from upstream svn +## +## DP: Re-structure the HTTP 1.1 headers to prevent 301s on servers with virtual hosts + +@DPATCH@ +diff -urNad nagios-plugins-1.4.12~/plugins/check_http.c nagios-plugins-1.4.12/plugins/check_http.c +--- nagios-plugins-1.4.12~/plugins/check_http.c 2008-08-23 15:41:49.000000000 +0200 ++++ nagios-plugins-1.4.12/plugins/check_http.c 2008-08-23 15:50:14.000000000 +0200 +@@ -749,15 +749,17 @@ + } + #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++) {