note 95592 deleted from function.get-headers by danbrown
| From: | danbrown@php.net | Date: | Mon, 11 Jan 2010 14:45:39 +0000 |
| Subject: | note 95592 deleted from function.get-headers by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164853@lists.php.net to get a copy of this message | ||
Note Submitter: php [spat] hm2k.org
----
In response to
http://www.php.net/manual/en/function.get-headers.php#90434
(gabe at vtunnel dot com)
This is a similar solution without using curl.
<?php
/**
* Fetches all the real headers sent by the server in response to a HTTP request without redirects
*
* @link http://php.net/function.get_headers
* @link http://bugs.php.net/bug.php?id=50719
*/
function get_real_headers($url,$format=0,$follow_redirect=0) {
if (!$follow_redirect) {
//set new default options
$opts = array('http' =>
array('max_redirects'=>1,'ignore_errors'=>1)
);
stream_context_get_default($opts);
}
//get headers
$headers=get_headers($url,$format);
//restore default options
if (isset($opts)) {
$opts = array('http' =>
array('max_redirects'=>20,'ignore_errors'=>0)
);
stream_context_get_default($opts);
}
//return
return $headers;
}
?>