[Nagiosplug-devel] [ nagiosplug-Bugs-2638765 ] check_http has wrong HTTP version when using "Host:"

SourceForge.net noreply at sourceforge.net
Wed Feb 25 23:24:53 CET 2009


Bugs item #2638765, was opened at 2009-02-26 09:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2638765&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General plugin execution
Group: Release (specify)
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Thiago Figueiro (thiagocsf)
Assigned to: Nobody/Anonymous (nobody)
Summary: check_http has wrong HTTP version when using "Host:"

Initial Comment:
The "Host" header does not exist in HTTP 1.0, but in HTTP 1.1 (see RFC for HTTP 1.0 http://www.faqs.org/rfcs/rfc2616.html and HTTP 1.1 http://www.faqs.org/rfcs/rfc1945.html)

The 1.4.13 (latest release) version of check_http issues requests like:

GET /myurl HTTP/1.0
User-Agent: check_http/v2053 (nagios-plugins 1.4.13)
Connection: close
Host: mydomain.com

This will cause web servers and load balancers to ignore the "Host: mydomain.com" header because the request was specified as HTTP/1.0.

The correct request is (notice "GET" line):

GET /myurl HTTP/1.1
User-Agent: check_http/v2053 (nagios-plugins 1.4.13)
Connection: close
Host: mydomain.com

A quick-and-dirty patch to fix this issue is below.

--- plugins-orig/check_http.c   2009-02-26 09:11:55.000000000 +1100
+++ plugins/check_http.c        2009-02-26 09:07:46.000000000 +1100
@@ -783,7 +783,11 @@
   }
 #endif /* HAVE_SSL */

+  if (host_name) {
+    asprintf (&buf, "%s %s HTTP/1.1\r\n%s\r\n", http_method, server_url, 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);



Best regards,
Thiago.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2638765&group_id=29880




More information about the Devel mailing list