Commit b074a132 authored by dmorley's avatar dmorley

Merge branch 'curl-timeout' into 'develop'

Curl timeout

See merge request diasporg/Poduptime!237
parents a18b81d4 3db36fc9
Pipeline #1456 passed with stage
in 2 minutes and 48 seconds
......@@ -4,6 +4,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
## [Unreleased]
### Added
### Changed
- curl function timeout can be changed from 15 second default
### Deprecated
### Removed
### Fixed
......
......@@ -31,7 +31,7 @@ $existingpods = array_column($pods, 'domain');
$foundpods = [];
//pulling all nodes for now
$federationpods = curl('https://the-federation.info/graphql?query=%7Bnodes%7Bhost%20platform%7Bname%7Dprotocols%7Bname%7D%7D%7D&raw');
$federationpods = curl('https://the-federation.info/graphql?query=%7Bnodes%7Bhost%20platform%7Bname%7Dprotocols%7Bname%7D%7D%7D&raw', false, 45);
if ($pods = json_decode($federationpods['body'] ?: '', true)) {
foreach ($pods['data']['nodes'] ?? [] as $poddata) {
$protocols = array_column($poddata['protocols'] ?? [], 'name');
......@@ -39,7 +39,7 @@ if ($pods = json_decode($federationpods['body'] ?: '', true)) {
}
}
$diasppods = curl('https://diasp.org/pods.json');
$diasppods = curl('https://diasp.org/pods.json', false, 45);
if ($pods = json_decode($diasppods['body'] ?: '', true)) {
foreach ($pods ?? [] as $poddata) {
$foundpods[] = strtolower($poddata['host']);
......
......@@ -105,12 +105,12 @@ function debug($label, $var = null, $dump = false): void
*
* @return array
*/
function curl(string $url, bool $follow = false): array
function curl(string $url, bool $follow = false, $timeout = 15): array
{
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, $url);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($chss, CURLOPT_TIMEOUT, 15);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($chss, CURLOPT_TIMEOUT, $timeout);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chss, CURLOPT_FAILONERROR, true);
curl_setopt($chss, CURLOPT_CERTINFO, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment