Class it_url:
/**
* Get simple URL with timeout and one retry. Can be called statically. Times out, calls it::error for all errs
*
* Request initiation
* @param $p parameter array with the following keys
* @param $p['url'] url to get, defaults to constructor URL
* @param $p['headers'] optional assoc array of HTTP headers to send, e.g. ['Host' => "foo"]
* @param $p['data'] POST data array with key-value pairs
* @param $p['files'] [fieldname => filename] of files to upload
* @param $p['maxlength'] maximum length of response
* @param $p['filemtime'] Add HTTP header to only fetch when newer than this, otherwise return true instead of data
* @param $p['accept_encoding'] Contents of the "Accept-Encoding: " header. Enables decoding of the response. Set to null to disable, "" (default) for all supported encodings.
* @param $p['protocols'] Array of protocols to accept, defaults to ['http', 'https'], @see curl_opts for other values
*
* Problem handling
* @param $p['retries'] Number of retries if download fails, default 1
* @param $p['timeout'] inactivity timeout seconds, default 5. fractions ok. silent by default
* @param $p['totaltimeout'] timeout for the whole attempt but see $['retry']
* @param $p['retrysleep'] Number of seconds to wait before retry (additional to fetchsleep), fractions ok
* @param $p['safety'] DEPRECATED. 0 = ignore errors, 1 = errors, 2 = fatals
* @param $p['it_error'] extra arguments for it_error or false to ignore errors
* @param $p['fetchsleep'] Number of seconds to wait after fetch, fractions ok
* @param $p['body_on_fail'] Return body of page even if http status code is >= 400, e.g. some JSON APIs return 404 with JSON data
*
* Result processing
* @param $p['assoc'] Return [ 'data' => string, 'status' => int, 'cookies' => array, 'headers' => array, 'errstr' => string ] instead of just data
* @param $p['writefunction'] function to be called whenever data is received (for server-sent-events etc.)
* @param $p['postprocess'] function called with content and $p which has it_error. returns content or null (which triggers retry)
* @param $p['followlocation']Follow redirects [true]
*
* @return Content of resulting page (considering redirects, excluding headers or false on error) or array if 'assoc' => true
*/
static function get($p = [])
{
return (new static)->_get($p);
}