From bb29c3272cfedc6bb5de1a216d587deccb1c8a49 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 9 Nov 2015 14:10:05 +0100 Subject: allow delay before retry --- it_url.class | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'it_url.class') diff --git a/it_url.class b/it_url.class index a54d1f6..fb5a1ff 100644 --- a/it_url.class +++ b/it_url.class @@ -156,6 +156,7 @@ function is_reachable($timeout = 5) * @param $p['filemtime'] Add HTTP header to only fetch when newer than this, otherwise return true instead of data * @param $p['data']: POST data array with key-value pairs * @param $p['retries']: Number of retries if download fails, default 1 + * @param $p['retrysleep'] Number of seconds to wait before retry, fractions ok * @return contents of resulting page, considering redirects, excluding headers, or false on error */ function get($p=null, $timeout=5) @@ -190,7 +191,10 @@ function get($p=null, $timeout=5) } if (!$result && $p['retries'] > 0 && $url->result < 400) + { + usleep($p['retrysleep']*1000000); $result = $url->get(array('retries' => $p['retries'] - 1) + $p); + } if (($filter = EDC('res')) && strstr($p['url'], it::replace(array('1' => ":"), $filter))) ED($result); -- cgit v1.2.3