summaryrefslogtreecommitdiffstats
path: root/web/attachments/291715-nagios-plugins-1.4.12-ommit-default-port.patch
blob: c43e6ed0490d0d3bf302ae3f18ef2bb3eafd5cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--- nagios-plugins-1.4.12-orig/plugins/check_http.c	2008-05-07 12:02:42.000000000 +0200
+++ nagios-plugins-1.4.12-ommit-default-port/plugins/check_http.c	2008-09-02 10:32:30.000000000 +0200
@@ -753,7 +753,17 @@
 
   /* optionally send the host header info */
   if (host_name)
-    asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
+  {
+    /* Ommit the server port if it's the standard port (80 for http and 443 for https). */
+    /* Some applications like wordpress do a redirect to a portless host if you named */
+    /* a portnumber like www.wordpress-thingy.invalid:80. It will redirect to */
+    /* www.wordpress-thingy.invalid and check_http adds the port number in the next */
+    /* http call again resulting in a "redirection creates an infinite loop" */
+    if ((use_ssl == false && server_port == HTTP_PORT) || (use_ssl == true && server_port == HTTPS_PORT))
+      asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
+    else
+      asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
+  }
 
   /* optionally send any other header tag */
   if (http_opt_headers_count) {