Explorar o código

Some HTTP server applications/configurations cause trouble if the port is
explicitly specified in our "Host:" header line. Therefore, we now specify the
port only if we're using a non-default port (Erik Wasser - 2082501).


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2053 f882894a-f735-0410-b71e-b25c423dba1c

Holger Weiss %!s(int64=17) %!d(string=hai) anos
pai
achega
8430be0b4b
Modificáronse 2 ficheiros con 13 adicións e 2 borrados
  1. 1 0
      THANKS.in
  2. 12 2
      plugins/check_http.c

+ 1 - 0
THANKS.in

@@ -237,3 +237,4 @@ Christian Schneemann
 Rob Windsor
 Hilko Bengen
 Sven Nierlein
+Erik Wasser

+ 12 - 2
plugins/check_http.c

@@ -789,8 +789,18 @@ check_http (void)
   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);
+  if (host_name) {
+    /*
+     * Specify the port only if we're using a non-default port (see RFC 2616,
+     * 14.23).  Some server applications/configurations cause trouble if the
+     * (default) port is explicitly specified in the "Host:" header line.
+     */
+    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) {