From: Jan Willamowius Date: Tue, 13 Sep 2005 13:44:27 +0000 (+0000) Subject: make HTTP version configurable, X-Git-Tag: spong-2_8_0-beta1~24 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8037a3238739f6b2587706031d340f994f780649;p=spong.git make HTTP version configurable, send UserAgent: Spong (so it can be filtered from web stats) --- diff --git a/src/lib/Spong/Network/plugins/check_http b/src/lib/Spong/Network/plugins/check_http index bbc5d88..25e43ba 100755 --- a/src/lib/Spong/Network/plugins/check_http +++ b/src/lib/Spong/Network/plugins/check_http @@ -10,12 +10,13 @@ sub check_http { my( $host ) = @_; my( @http_files ) = ( @{$HTTPDOCS{"ALL"}}, @{$HTTPDOCS{$host}} ); my( $http_port ) = $HTTPPORT{$host} || $HTTPPORT{"ALL"} || 80; + my( $http_version ) = $HOSTS{$host}->{'http_version'} || $HTTPVERSION{$host} || $HTTPVERSION{"ALL"} || $HTTPVERSION{"DEFAULT"} || "1.1"; # Find list of URL's to check my( @http_urls ) = @{$HTTPURLS{$host}}; - @http_urls = @{$HTTPURLS{'DEFAULT'}} if( ! @http_urls ); @http_urls = @{$HOSTS{$host}->{'http_urls'}} if( ! @http_urls ); @http_urls = @{$HOSTS_DEFAULTS{'http_urls'}} if( ! @http_urls ); + @http_urls = @{$HTTPURLS{'DEFAULT'}} if( ! @http_urls ); # Append mandatory urls to check @http_urls = ( @http_urls, @{$HOSTS_ALL{'http_urls'}} ); @@ -29,6 +30,7 @@ sub check_http { # Parse the URL into it's components $url =~ s|^([A-Z]+ )?http://||; # Remove the protocol id if present $method = $1 || "HEAD"; + chop($method); # remove trailing space my($hpart,$urlpath) = ( $url =~ m|^([^/]+)(/.*)| ); my($hname,$port) = split(/:/,$hpart); $port = 80 if ! $port; @@ -40,9 +42,10 @@ sub check_http { $url =~ s/_HOST_/$host/; } + my $checkarg = "\r\nHost: $hname:$port" if ($http_version ne "1.0"); my $message = &check_tcp( $hname, $port, - "$method $urlpath HTTP/1.1\r\nHost: $hname:$port\r\n\r\n", 10 ); + "$method $urlpath HTTP/$http_version$checkarg\r\nUser-Agent: Spong\r\n\r\n", 10 ); if( $message =~ /HTTP\S+\s+(\d\d\d)\s.*$/m ) { my $code = $1; @@ -63,14 +66,14 @@ sub check_http { if( $color ne "red" ) { $color = "yellow"; $summary = "can't determine status code";} } - $tmessage .= "->$method $urlpath HTTP/1.1\nHost: $hname:$port\n$message\n\n"; + $tmessage .= "->$method $urlpath HTTP/$http_version$checkarg\n$message\n\n"; } } else { foreach $file ( @http_files ) { my $message = - &check_tcp( $host, $http_port, "HEAD $file HTTP/1.0\r\n\r\n", 10 ); + &check_tcp( $host, $http_port, "GET $file HTTP/1.0\r\nUser-Agent: Spong\r\n\r\n", 10 ); if( $message =~ /HTTP\S+\s+(\d\d\d)\s.*$/m ) { my $code = $1;