set low timeout for version-check and output message if check is not possible (due to connection error, downtime of server, etc.)

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2019-10-06 18:53:30 +02:00
parent fa3e3da7ac
commit 55d21e475d
3 changed files with 12 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ class HttpClient
*
* @return array
*/
public static function urlGet($url, $follow_location = true)
public static function urlGet($url, $follow_location = true, $timeout = 10)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -19,6 +19,7 @@ class HttpClient
if ($follow_location) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
if ($output === false) {