diff options
author | Urban Müller | 2015-11-09 14:10:05 +0100 |
---|---|---|
committer | Urban Müller | 2015-11-09 14:10:05 +0100 |
commit | bb29c3272cfedc6bb5de1a216d587deccb1c8a49 (patch) | |
tree | 15bb5e9a60320a56f97dcdcbd673abbb313d5ee8 | |
parent | da71e326d6bbd7e531f0948cac99cf0c4d51ad6e (diff) | |
download | itools-bb29c3272cfedc6bb5de1a216d587deccb1c8a49.tar.gz itools-bb29c3272cfedc6bb5de1a216d587deccb1c8a49.tar.bz2 itools-bb29c3272cfedc6bb5de1a216d587deccb1c8a49.zip |
allow delay before retry
-rw-r--r-- | it_url.class | 4 |
1 files changed, 4 insertions, 0 deletions
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); |