How is it possible that get_headers()
could possibly return a different result than getting them by CURL? Here is my code:
header("Content-type: text/plain");
$url = 'http://www.foxbusiness.com/index.html';
echo "get_headers() headers:
";
$headers = get_headers($url);
print_r($headers);
echo "
CURL headers
";
$curl = curl_init();
curl_setopt_array( $curl, array(
CURLOPT_HEADER => true,
CURLOPT_NOBODY => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url ) );
$headers = explode( "
", curl_exec( $curl ) );
curl_close( $curl );
print_r($headers);
This is the result:
get_headers() headers:
Array
(
[0] => HTTP/1.0 403 Forbidden
[1] => Server: AkamaiGHost
[2] => Mime-Version: 1.0
[3] => Content-Type: text/html
[4] => Content-Length: 283
[5] => Expires: Fri, 31 Aug 2012 07:29:14 GMT
[6] => Date: Fri, 31 Aug 2012 07:29:14 GMT
[7] => Connection: close
)
CURL headers
Array
(
[0] => HTTP/1.1 200 OK
[1] => Server: Apache
[2] => X-FoxNews-EdgeTTL: 2m
[3] => Content-Type: text/html;charset=UTF-8
[4] => Cache-Control: max-age=64
[5] => Date: Fri, 31 Aug 2012 07:29:14 GMT
[6] => Connection: keep-alive
[7] =>
[8] =>
)