LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: ldirectord and HTTP GET/HEAD [patch]

To: Volker Dormeyer <volker@xxxxxxxxxxxxxxxxx>, lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: ldirectord and HTTP GET/HEAD [patch]
From: Volker Dormeyer <volker@xxxxxxxxxxxx>
Date: Mon, 21 Feb 2005 21:40:46 +0100
Sorry again, the patch (MIME attachement) seemed to be cut by the
mailing list software. Here it is again as text:

--- ldirectord.orig     2005-02-09 09:19:51.000000000 +0100
+++ ldirectord  2005-02-21 21:07:28.000000000 +0100
@@ -265,6 +265,12 @@
 
 For a MySQL check, the receive setting is not used.
 
+B<httpmethod = GET>|B<HEAD>
+
+Sets the HTTP method which should be used to fetch the URI specified in
+the request-string. GET is the method used by default if the parameter is
+not set. If HEAD is used, the receive-string should be unset.
+
 B<virtualhost = ">I<hostname>B<">
 
 Used when using a negotiate check with HTTP or HTTPS. Sets the host header
@@ -712,6 +718,7 @@
                        $vsrv{connecttimeout} = 0;
                        $vsrv{negotiatetimeout} = 0;
                        $vsrv{num_connects} = 0;
+                       $vsrv{httpmethod} = "GET";
                        push(@VIRTUAL, \%vsrv);
                        while(<CFGFILE>) {
                                $line++;
@@ -826,6 +833,10 @@
                                                        $vsrv{login} eq "") {
                                                $vsrv{login} = "anonymous";
                                        }
+                               } elsif ($rcmd =~ /^httpmethod\s*=\s*(.*)/) {
+                                       $1 =~ /(\w+)/ && (uc($1) eq "GET" || 
uc($1) eq "HEAD")
+                                           or &config_error($line, "httpmethod 
must be GET or HEAD");
+                                       $vsrv{httpmethod} = uc($1);
                                } elsif ($rcmd =~ /^virtualhost\s*=\s*(.*)/) {
                                        $1 =~ /\"?([^"]*)\"?/ or
                                        &config_error($line, "invalid 
virtualhost");
@@ -1675,7 +1686,7 @@
        my $ua = new LWP::UserAgent();
        $ua->timeout($$v{negotiatetimeout});
        my $h = new  HTTP::Headers("Host" => $virtualhost);
-       my $req = new HTTP::Request("GET", "$$r{url}", $h);
+       my $req = new HTTP::Request("$$v{httpmethod}", "$$r{url}", $h);
        my $res;
        {
                # LWP makes ungaurded calls to eval
@@ -1848,7 +1859,7 @@
        }
        my $virtualhost = (defined $$v{virtualhost} ? $$v{virtualhost} : $host);
        my ($page, $errors, $cert, $head, $body, $response, $result);
-       my $msg = "GET $uri HTTP/1.0" . $CRLF
+       my $msg = "$$v{httpmethod}" . " $uri HTTP/1.0" . $CRLF
                . "Host: " . $virtualhost . $CRLF
                . "Accept: */*" . $CRLF . $CRLF;
 
 //> On Mon, 21 Feb 2005 21:34:19 +0100,
 //> Volker Dormeyer <volker@xxxxxxxxxxxx> wrote:

  > I'm sorry, the patch file was created in the wrong order. Here is a new
  > one.

  > Regards
  > Volker


 //> On Mon, 21 Feb 2005 21:29:54 +0100,
 //> Volker Dormeyer <volker@xxxxxxxxxxxx> wrote:

 >> Hello,

 >> ldirectord does HTTP/HTTPS health checking by the HTTP GET method. I
 >> know of some people and one of our customers who would like to use the
 >> HTTP HEAD method for health checking to avoid the retrieval of an entire
 >> web page. Which in turn results in a log entry of the web server and
 >> after all in a web page hit.

 >> Thus, I wrote a small patch to make ldirectord able to issue HTTP HEAD
 >> requests for HTTP/HTTPS health checking. The attached patch adds an
 >> additional config file parameter "httpmethod" which can be either "GET"
 >> or "HEAD". It defaults to "GET", if it is not set in order to not break
 >> any existing setups.

 >> What do you think about it? Contructive ideas or criticism are welcome!
 >> Maybe this was discussed some time ago.




<Prev in Thread] Current Thread [Next in Thread>