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'}} );
# 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;
$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;
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;