check if http_response_header is defined

This commit is contained in:
Andrew Dolgov 2013-04-19 09:48:09 +04:00
parent b367c951b9
commit df25e4d221
1 changed files with 7 additions and 5 deletions

View File

@ -394,6 +394,7 @@
$data = @file_get_contents($url); $data = @file_get_contents($url);
$fetch_last_content_type = false; // reset if no type was sent from server $fetch_last_content_type = false; // reset if no type was sent from server
if (is_array($http_response_header)) {
foreach ($http_response_header as $h) { foreach ($http_response_header as $h) {
if (substr(strtolower($h), 0, 13) == 'content-type:') { if (substr(strtolower($h), 0, 13) == 'content-type:') {
$fetch_last_content_type = substr($h, 14); $fetch_last_content_type = substr($h, 14);
@ -401,6 +402,7 @@
// e.g. if we were being redirected -- last one is the right one // e.g. if we were being redirected -- last one is the right one
} }
} }
}
if (!$data && function_exists('error_get_last')) { if (!$data && function_exists('error_get_last')) {
$error = error_get_last(); $error = error_get_last();