{
$options = array(
'method' => strtoupper($method));
if (isset($data))
{
if (is_scalar($data))
{
}
else
{
$options[
'content'] = http_build_query($data);
}
if (!isset($headers['Content-Type']))
{
$headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8';
}
$headers[
'Content-Length'] = strlen(
$options[
'content']);
}
$headerString = null;
if (isset($headers))
{
foreach ($headers as $key => $value)
{
$headerString .= $key . ': ' . $value . "\r\n";
}
$options[
'header'] = trim($headerString,
"\r\n");
}
if (isset($timeout))
{
}
if (isset($userAgent))
{
}
$options[
'follow_location'] = (int) $this->options->get(
'follow_location', 1);
$context = stream_context_create(array(
'http' =>
$options));
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$stream = @fopen((string) $uri, 'r', false, $context);
if (!$stream)
{
if (!$php_errormsg)
{
$php_errormsg = sprintf('Could not connect to resource: %s', $uri, $err, $errno);
}
ini_set('track_errors', $track_errors);
throw new RuntimeException($php_errormsg);
}
ini_set('track_errors', $track_errors);
$metadata = stream_get_meta_data($stream);
$content = stream_get_contents($stream);
fclose($stream);
if (isset($metadata['wrapper_data']['headers']))
{
$headers = $metadata['wrapper_data']['headers'];
}
elseif (isset($metadata['wrapper_data']))
{
$headers = $metadata['wrapper_data'];
}
else
{
$headers = array();
}
}