From f861e9bde29fb3d2e65e9df06c296ea0e45f07f4 Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Tue, 6 Nov 2018 14:18:56 +0100 Subject: 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 --- it_url.class | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3