Returns exception in error case and addas a timeout to kea curl

pull/6/head
Luis Gerardo Romero Garcia 2023-11-21 10:24:45 +01:00
parent 38dfce9dd6
commit 7d49912fb8
1 changed files with 5 additions and 6 deletions

View File

@ -288,10 +288,6 @@ function executeCurlCommand($command, $arguments = null, $create_backup = true)
if (($command == 'config-set' || $command == 'config-write') && $create_backup) {
backupConfig();
}
$headers = array(
'Access-Control-Allow-Origin: *',
'Access-Control-Allow-Methods: GET, POST, OPTIONS',
);
$jsonData = json_encode($requestData);
try{
$ch = curl_init();
@ -302,6 +298,7 @@ function executeCurlCommand($command, $arguments = null, $create_backup = true)
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@ -316,10 +313,12 @@ function executeCurlCommand($command, $arguments = null, $create_backup = true)
return $output;
} else {
return false;
$error = curl_error($ch);
throw new Exception($error);
//return false;
}
} catch (Exception $e) {
throw new Exception('Error al ejecutar la solicitud Curl: ' . $e->getMessage());
throw new Exception($e->getMessage());
}
}