'(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')', ]; if ($allowRedirects) { $options = [ 'allow_redirects' => [ 'max' => 2, 'strict' => true, ], ]; } else { $options = [ 'allow_redirects' => false, ]; } try { $res = Http::withOptions($options) ->retry(3, function (int $attempt, $exception) { return $attempt * 500; }) ->acceptJson() ->withHeaders($headers) ->timeout(40) ->get($url); } catch (RequestException $e) { Cache::put($key, 1, $ttl); return false; } catch (ConnectionException $e) { Cache::put($key, 1, $ttl); return false; } catch (Exception $e) { Cache::put($key, 1, $ttl); return false; } if (! $res->ok()) { Cache::put($key, 1, $ttl); return false; } return $res->json(); } }