If HTTP method is 'HEAD', server will send only HTTP header and never send HTTP content.
If HTTP method is 'GET', server will send both HTTP header and HTTP content.
So, use HTTP::Response->as_string when HTTP method is 'HEAD', and use HTTP::Response->content when HTTP method is 'GET'.
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 $response = $v->{httpmethod} eq "HEAD" ? $res->as_string : $res->content;
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);