distroquery.php: add a 15 seconds timeout to all API requests

This commit is contained in:
Silvan Calarco 2024-12-07 00:43:56 +01:00
parent 00584e2f08
commit 06122a2040

View File

@ -42,6 +42,11 @@ $url_prefix = home_url() . "/rpms/";
$package=get_query_var('package');
$arch=get_query_var('arch');
$get_args = array(
'timeout' => 15,
'sslverify' => false
);
if ($repo == "") {
//
@ -50,7 +55,7 @@ $url_prefix = home_url() . "/rpms/";
echo " > " . _r("Repositories");
echo "<h1>" . _r("Available repositories") . ":</h1>";
$request = wp_remote_get($api_url . "repositories");
$request = wp_remote_get($api_url . "repositories", $get_args);
if (is_wp_error($request)) {
echo "<p>ERROR: " . $request->get_error_message() . "</p>";
goto finish;
@ -75,7 +80,7 @@ $url_prefix = home_url() . "/rpms/";
if ($q != "") $query_append .= "&q=" . urlencode($q);
if (strlen($query_append) > 0 && $query_append[0] == '&') $query_append[0] = "?";
$request = wp_remote_get($api_url . "repository/" . $repo . $query_append);
$request = wp_remote_get($api_url . "repository/" . $repo . $query_append, $get_args);
if (is_wp_error($request)) {
echo "<p>ERROR: " . $request->get_error_message() . "</p>";
goto finish;
@ -176,7 +181,7 @@ $url_prefix = home_url() . "/rpms/";
//
echo " > <a href=\"" . $url_prefix . "\">" . _r("Repositories") . "</a>";
$request = wp_remote_get($api_url . "package/" . $repo . "/" . $package);
$request = wp_remote_get($api_url . "package/" . $repo . "/" . $package, $get_args);
if (is_wp_error($request)) {
echo "<p>ERROR: " . $request->get_error_message() . "</p>";
goto finish;
@ -278,8 +283,7 @@ $url_prefix = home_url() . "/rpms/";
//
echo " > <a href=\"" . $url_prefix . "\">" . _r("Repositories") . "</a>";
$request = wp_remote_get($api_url . "package/" . $repo . "/" . $package . "/" . $arch,
array('timeout' => 15));
$request = wp_remote_get($api_url . "package/" . $repo . "/" . $package . "/" . $arch, $get_args);
if (is_wp_error($request)) {
echo "<div class=\"errorbox\">ERROR: " . $request->get_error_message() . "</div>";
goto finish;