summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
authorChristian Helbling2018-11-06 14:18:56 +0100
committerChristian Helbling2018-11-06 14:18:56 +0100
commitf861e9bde29fb3d2e65e9df06c296ea0e45f07f4 (patch)
treee31e3ad4a51f9f95000705afeedb146d755560e0 /it_url.class
parent8d4cff2539ff117d5ea4616b27ef7de2aa400bd4 (diff)
downloaditools-f861e9bde29fb3d2e65e9df06c296ea0e45f07f4.tar.gz
itools-f861e9bde29fb3d2e65e9df06c296ea0e45f07f4.tar.bz2
itools-f861e9bde29fb3d2e65e9df06c296ea0e45f07f4.zip
add new parameter fetchsleep to sleep after a fetch - this parameter is useful for it_url::get_cache_contents when fetching many resources from an external server: it sleeps after every fetch on the external server but doesn't when fetching from cache
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class5
1 files changed, 4 insertions, 1 deletions
diff --git a/it_url.class b/it_url.class
index 8ee76b9..d196c54 100644
--- a/it_url.class
+++ b/it_url.class
@@ -103,8 +103,9 @@ function is_reachable($timeout = 5)
* @param $p['data'] POST data array with key-value pairs
* @param $p['files'] [fieldname => filename] of files to upload
* @param $p['writefunction'] function to be called whenever data is received (for server-sent-events etc.)
+ * @param $p['fetchsleep'] Number of seconds to wait after fetch, fractions ok
* @param $p['retries'] Number of retries if download fails, default 1
- * @param $p['retrysleep'] Number of seconds to wait before retry, fractions ok
+ * @param $p['retrysleep'] Number of seconds to wait before retry (additional to fetchsleep), fractions ok
* @param $p['compression'] use compression (uses curl to do that)
* @return contents of resulting page, considering redirects, excluding headers, or false on error
*/
@@ -139,6 +140,8 @@ function get($p=null, $timeout=5)
if (($filter = EDC('res')) && strstr($p['url'], it::replace(array('1' => ":"), $filter)))
ED($result);
+ usleep($p['fetchsleep'] * 1000000);
+
return $result;
}