From: Stephen L Johnson Date: Thu, 17 Jan 2002 20:33:39 +0000 (+0000) Subject: added method patch from David Bronder that allows check method (i.e. GET, HEAD) to... X-Git-Tag: spong-2_7_7~19 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=835547c61d6108df4d2d4797c63a59d4e3e2fd10;p=spong.git added method patch from David Bronder that allows check method (i.e. GET, HEAD) to be specified in URI line --- diff --git a/src/lib/Spong/Network/plugins/check_http b/src/lib/Spong/Network/plugins/check_http index f807216..bbc5d88 100755 --- a/src/lib/Spong/Network/plugins/check_http +++ b/src/lib/Spong/Network/plugins/check_http @@ -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 {