diff options
author | Christian Helbling | 2018-11-06 14:18:56 +0100 |
---|---|---|
committer | Christian Helbling | 2018-11-06 14:18:56 +0100 |
commit | f861e9bde29fb3d2e65e9df06c296ea0e45f07f4 (patch) | |
tree | e31e3ad4a51f9f95000705afeedb146d755560e0 | |
parent | 8d4cff2539ff117d5ea4616b27ef7de2aa400bd4 (diff) | |
download | itools-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
-rw-r--r-- | it_url.class | 5 |
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; } |