protected function _stream($url, $options)
{
$eol = "\r\n";
$options['header'] = implode($eol, $options['header']);
$body = @file_get_contents($url, FALSE, stream_context_create(['http' => $options]));
$headers = isset($http_response_header) ? $http_response_header : [];
$err = '';
if (is_string($body)) {
$match = NULL;
foreach ($headers as $header) {
if (preg_match('/Content-Encoding: (.+)/', $header, $match)) {
break;
}
}
if ($match) {
switch ($match[1]) {
case 'gzip':
$body = gzdecode($body);
break;
case 'deflate':
$body = gzuncompress($body);
break;
}
}
} else {
$tmp = error_get_last();
$err = $tmp['message'];
}
return ['body' => $body, 'headers' => $headers, 'engine' => 'stream', 'cached' => FALSE, 'error' => $err];
}