Improved error detection when calling curl.

Ref. pandora_enterprise#8359.
This commit is contained in:
Ramon Novoa 2022-09-22 17:04:43 +02:00
parent fdd6699de5
commit 6c506e9dd0
2 changed files with 12 additions and 0 deletions

View File

@ -336,6 +336,9 @@ sub curl {
my $cmd = "curl $curl_opts " . safe_param($url);
my $response = `"$exec" $timeout $cmd 2>/dev/null`;
if ($? == -1) {
die("Error calling curl. Not enough memory?\n");
}
# Curl command stored for live debugging feature.
set_update_agentmodule ($dbh, $moduleId, { 'debug_content' => $cmd }) if defined($dbh);

View File

@ -110,6 +110,9 @@ sub g_http_task {
my $get_content_advanced = "";
my $ua = new LWP::UserAgent;
if (!defined($ua)) {
die("LWP::UserAgent->new() failed. Not enough memory?");
}
$task_requests [$thread_id] = 0 ;
$task_sessions [$thread_id] = 0 ;
$task_reqsec[$thread_id] = 0;
@ -388,6 +391,9 @@ sub g_get_page {
my $debug = $_[3];
my $req = HTTP::Request->new(GET => $url);
if (!defined($req)) {
die("HTTP::Request->new() failed. Not enough memory?");
}
$req->header('Accept' => 'text/html');
while (my ($header, $value) = each %{$headers}) {
$req->header($header => $value);
@ -418,6 +424,9 @@ sub g_head_page {
my $debug = $_[3];
my $req = HTTP::Request->new(HEAD => $url);
if (!defined($req)) {
die("HTTP::Request->new() failed. Not enough memory?");
}
$req->header('Accept' => 'text/html');
while (my ($header, $value) = each %{$headers}) {
$req->header($header => $value);