note 95592 added to function.get-headers
| From: | php | Date: | Mon, 11 Jan 2010 13:09:57 +0000 |
| Subject: | note 95592 added to function.get-headers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164850@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 82.152.138.226
----
Manual Page -- http://www.php.net/manual/en/function.get-headers.php
Edit -- https://master.php.net/note/edit/95592
Del: integrated -- https://master.php.net/note/delete/95592/integrated
Del: useless -- https://master.php.net/note/delete/95592/useless
Del: bad code -- https://master.php.net/note/delete/95592/bad+code
Del: spam -- https://master.php.net/note/delete/95592/spam
Del: non-english -- https://master.php.net/note/delete/95592/non-english
Del: in docs -- https://master.php.net/note/delete/95592/in+docs
Del: other reasons-- https://master.php.net/note/delete/95592
Reject -- https://master.php.net/note/reject/95592
Search -- https://master.php.net/manage/user-notes.php