]> git.etc.gen.nz Git - spong.git/commitdiff
added method patch from David Bronder that allows check method (i.e. GET, HEAD) to...
authorStephen L Johnson <sjohnson@monsters.org>
Thu, 17 Jan 2002 20:33:39 +0000 (20:33 +0000)
committerStephen L Johnson <sjohnson@monsters.org>
Thu, 17 Jan 2002 20:33:39 +0000 (20:33 +0000)
src/lib/Spong/Network/plugins/check_http

index f8072160d77b494ccea61daa554e6d86fd496d4b..bbc5d88d6b5eec164a2f75f23de5e6ff8965c997 100755 (executable)
@@ -20,14 +20,15 @@ sub check_http {
    # Append mandatory urls to check
    @http_urls = ( @http_urls, @{$HOSTS_ALL{'http_urls'}} ); 
 
-   my( $file, $tmessage ) = ( "", "" );
+   my( $file, $tmessage, $method ) = ( "", "" );
    my( $color, $summary ) = ( "green", "" );
 
    # If HTTP URLS are defined use the URL check
    if ( @http_urls ) {
       foreach my $url (@http_urls) {
          # Parse the URL into it's components
-         $url =~ s|^http://||;  # Remove the protocol id if present
+         $url =~ s|^([A-Z]+ )?http://||;  # Remove the protocol id if present
+         $method = $1 || "HEAD";
          my($hpart,$urlpath) = ( $url =~ m|^([^/]+)(/.*)| );
          my($hname,$port) = split(/:/,$hpart);
          $port = 80 if ! $port;
@@ -41,7 +42,7 @@ sub check_http {
          
          my $message = 
            &check_tcp( $hname, $port,
-               "HEAD $urlpath HTTP/1.1\r\nHost: $hname:$port\r\n\r\n", 10 );
+               "$method $urlpath HTTP/1.1\r\nHost: $hname:$port\r\n\r\n", 10 );
 
          if( $message =~ /HTTP\S+\s+(\d\d\d)\s.*$/m ) {
             my $code = $1;
@@ -62,7 +63,7 @@ sub check_http {
            if( $color ne "red" ) {
               $color = "yellow"; $summary = "can't determine status code";}
          }
-         $tmessage .= "->HEAD $urlpath HTTP/1.1\nHost: $hname:$port\n$message\n\n";
+         $tmessage .= "->$method $urlpath HTTP/1.1\nHost: $hname:$port\n$message\n\n";
       }
 
    } else {