Loads static-data for given URL. First from cache, if it doesnt exist,
try to fetch up-to date from web.

@param string        $url
@param callable|null $processing  (string $url, array $data)

@return array
@throws ArgumentException
549142
protected static function loadStaticData( string $url, callable $processing = null ): array
	{
		$urlHash = md5($url);

		$data = self::loadCachedStaticData($url);
		if ($data) return $data;

		//  Lastly try loading from web
		$data = @file_get_contents($url);
		if ($data == false)
			throw new ArgumentException("Failed to load static-data for URL: '$url'.");

		$data = json_decode($data, true);
		//  Save to memory
		self::$staticData[$urlHash] = $data;

		self::saveSataicData($urlHash, $data);
		if ($processing) $processing($url, $data);
		return $data;
	}
468389
static public function postArray($url, $data, $options=null)
    {
        $instance = new static('POST', $url, $data, $options);
        return $instance->toArray();
    }
801986
public function loadFromUrl(string $url, array $options = [], CurlInterface $curl = null): Dom
    {
        if (is_null($curl)) {
            // use the default curl interface
            $curl = new Curl;
        }
        $content = $curl->get($url);

        return $this->loadStr($content, $options);
    }
152643
public function processUrl($url)
    {
        if (strpos($url, '::') !== false) {
            list($folder, $asset) = explode('::', $url, 2);
        } else {
            $folder = null;
            $asset = $url;
        }

        if (empty($asset)) {
            return false;
        }

        return array(
            'folder' => $folder,
            'asset' => $asset
        );
    }
348381
public function loadFile($url)
    {
        //Locate the template
        $locator = $this->getObject('template.locator.factory')->createLocator($url);

        if (!$file = $locator->locate($url)) {
            throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url));
        }

        //Load the template
        if(!$source = file_get_contents($file)) {
            throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file));
        }

        $this->_source = $source;

        return $this;
    }
15787
public function loadUrl($url, $curl = false) {
        if ($curl) {
            $content = self::loadContent($url);
            if (empty($content)) {
                throw new Exception("Can't get content from " . $url);
            }
            $this->loadString($content);
        } else {
            $this->load_file($url);
        }
    }
1093938
def _load(self, url):
        
        self._logger.debug('Loading url %s into resource cache' % url)
        retriever = get_resource_retriever(url)
        content_path = os.path.join(self.path, self._hash_path(url))

        try:
            if url in self.metadata:
                headers = retriever.fetch(content_path, last_etag=self.metadata[url]['etag'], progress_bar=self.progress_bars)
                if headers is None:
                    # no update, return what is already loaded
                    self._logger.info('Cached %s is up-to-date. No data download needed' % url)
                    return self.metadata[url]
            else:
                headers = retriever.fetch(content_path, progress_bar=self.progress_bars)
                if headers is None:
                    raise Exception('Fetch of %s failed' % url)

            if 'etag' not in headers:
                # No Etag returned, so generate it
                headers['etag'] = fs_util.calc_file_md5(content_path)

            # Populate metadata from the headers
            self.metadata[url] = headers.copy()
            self.metadata[url]['content'] = content_path
            return self.metadata[url]
        except:
            self._logger.error('Failed getting resource: %s')

            # forcibly flush local entry if found
            if url in self.metadata:
                self.metadata.pop(url)
            raise
        finally:
            if url not in self.metadata:
                self._logger.debug('Cleaning up on failed load of %s' % url)
                # Cleanup on failure
                if content_path is not None and os.path.exists(content_path):
                    os.remove(content_path)
859656
public function load($url)
    {
        if (is_readable($url) === false) {
            $msg = "The PHP document located at '${url}' is not readable or does not exist.";
            throw new PhpStorageException($msg, PhpStorageException::READ);
        }

        try {
            // Will return $rootcomponent.
            require $url;
            $this->setDocumentComponent($rootcomponent);
            $this->setUrl($url);
        } catch (Exception $e) {
            $msg = "A PHP Runtime Error occured while executing the PHP source code representing the document to be loaded at '${url}'.";
            throw new PhpStorageException($msg, PhpStorageException::UNKNOWN, $e);
        }
    }
326430
private function addGetData($url, $data) {
        $parts[] = $url;
        if (!empty($data)) {
            $parts[] = http_build_query($data);
        }
        return implode('?', $parts);
    }
907991
public function get($url, array $data = [])
    {
        if (count($data) > 0) {
            $this->setopt(CURLOPT_URL, $url.'?'.http_build_query($data));
        } else {
            $this->setopt(CURLOPT_URL, $url);
        }
        $this->setopt(CURLOPT_HTTPGET, true);
        $this->_exec();
    }
904372
public function get($url, $data = null, $header = [])
    {
        $url = URLUtil::addParameter($url, $data);
        return $this->exec($url, $data, 'get', $header);
    }
1008756
public function parse($url)
    {
        foreach ($this->map as $pattern) {
            $pattern = $this->compile($pattern);
            if (preg_match($pattern, $url, $match)) {
                // remove numeric keys
                foreach ($match as $key => $value) {
                    if (is_numeric($key)) {
                        unset($match[$key]);
                    }
                }

                return $match;
            }
        }

        throw new Exceptions\InvalidArgumentException("URL '$url' did not match any route.");
    }
1317925
static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE)
    {
        $components = parse_url($url);

        if ($components === false) {
            throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url));
        }

        $query = [];

        if (isset($components['query'])) {
            parse_str($components['query'], $query);
        }

        return new static(
            $components['scheme'] ?? null,
            $components['host'] ?? null,
            $components['port'] ?? null,
            $components['path'] ?? '',
            $query,
            $components['fragment'] ?? null,
            $preferredFormat
        );
    }
1132224
private function parseUrl(string $url): array
    {
        $parts = parse_url($url);

        if ($parts === false || !isset($parts['host'])) {
            throw new \InvalidArgumentException(sprintf('Invalid connection URL given: "%s"', $url));
        }

        $params = [
            'login' => $parts['user'] ?? '',
            'password' => $parts['pass'] ?? '',
            'host' => $parts['host'],
            'port' => (int) ($parts['port'] ?? 5672),
            'vhost' => empty($parts['path']) || $parts['path'] === '/' ? '/' : substr($parts['path'], 1),
        ];

        parse_str($parts['query'] ?? '', $queryParams);

        return $params + $queryParams;
    }
1250336
public function postJSON($url, $data = null)
    {
        $responseBody = $this->post($url, json_encode($data), 'application/json');

        return json_decode($responseBody);
    }
1280770
public function process(HTTPRequest $request, callable $delegate)
    {
        /** @var HTTPResponse $response */
        $response = $delegate($request);
        if (!$response) {
            return null;
        }

        // Ignore etag for no-store
        $cacheControl = $response->getHeader('Cache-Control');
        if ($cacheControl && strstr($cacheControl, 'no-store')) {
            return $response;
        }

        // Generate, assign, and conditionally check etag
        $etag = $this->generateETag($response);
        if ($etag) {
            $response->addHeader('ETag', $etag);

            // Check if we have a match
            $ifNoneMatch = $request->getHeader('If-None-Match');
            if ($ifNoneMatch === $etag) {
                return $this->sendNotModified($request, $response);
            }
        }

        // Check If-Modified-Since
        $ifModifiedSince = $request->getHeader('If-Modified-Since');
        $lastModified = $response->getHeader('Last-Modified');
        if ($ifModifiedSince && $lastModified && strtotime($ifModifiedSince) >= strtotime($lastModified)) {
            return $this->sendNotModified($request, $response);
        }

        return $response;
    }
475217
private function getRemoteData(string $url): ResponseInterface
    {
        $context      = $this->streamHelper->getStreamContext();
        $stream       = @fopen($url, 'rb', false, $context);

        if (false === $stream) {
            throw new Exception('could not initialize the connection to load the data');
        }

        $timeout = $this->loader->getTimeout();

        stream_set_timeout($stream, $timeout);
        stream_set_blocking($stream, true);

        $meta    = stream_get_meta_data($stream);
        $headers = [];
        $code    = 200;

        if (isset($meta['wrapper_data']) && is_array($meta['wrapper_data'])) {
            $headers = $meta['wrapper_data'];

            foreach ($headers as $metaData) {
                if ('http/' === mb_substr(mb_strtolower($metaData), 0, 5)) {
                    $tmp_status_parts = explode(' ', $metaData, 3);
                    $code             = $tmp_status_parts[1];

                    break;
                }
            }
        }

        return new Response($code, $headers, new Stream($stream));
    }