OSDN Git Service

Fixed bug: Evaluated the header section with the body section in HTTP negotiate check.
authorShinya TAKEBAYASHI <makoto@kanon-net.jp>
Wed, 7 Oct 2009 02:48:19 +0000 (11:48 +0900)
committerShinya TAKEBAYASHI <makoto@kanon-net.jp>
Wed, 7 Oct 2009 02:48:19 +0000 (11:48 +0900)
Normally, evaluates only the body section in GET check.
But l7directord was evaluates with body section and header section.

This problem was fixed, l7directord become the following operation.

  * In the case of "httpmethod = HEAD":

      Evaluates only the header(Includes HTTP response code) section.

  * In the case of "httpmethod = GET":

      Evaluates only the body section.

l7directord/l7directord

index f628f24..f986823 100755 (executable)
@@ -2124,12 +2124,21 @@ sub check_http {
     my $status_line = $res->status_line;
     $status_line =~ s/[\r\n]//g;
 
+    my $response = "";
+    my ($res_head, $res_body) = split /\n\n/, $res->as_string, 2;
+    if ($v->{httpmethod} eq "HEAD") {
+       $response = $res_head;
+    }
+    else {
+       $response = $res_body;
+    }
+
     my $recstr = $r->{receive};
     if (!$res->is_success) {
         ld_log( _message( 'WRN1102', $status_line, $r->{server}{ip}, $port ) ) if (!defined $status || $status eq $SERVICE_UP);
         return $SERVICE_DOWN;
     }
-    elsif (defined $recstr && $res->content !~ /$recstr/) {
+    elsif (defined $recstr && $response !~ /$recstr/) {
         ld_log( _message( 'WRN1103', $recstr, $r->{server}{ip}, $port ) ) if (!defined $status || $status eq $SERVICE_UP);
         ld_debug(3, "HTTP Response " . $res->headers->as_string);
         ld_debug(2, "check_http: $r->{url} is down\n");