note 45420 added to function.get-headers
| From: | cpurrucfh-landshutde at osu1 dot php dot net | Date: | Mon, 06 Sep 2004 16:42:11 +0000 |
| Subject: | note 45420 added to function.get-headers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76107@lists.php.net to get a copy of this message | ||
Both backports are bad! For getting header meta data, you should use HEAD instead of GET.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4
for details!
<?php
/**
* @return array
* @param string $url
* @desc Fetches all the headers
* @author cpurruc fh-landshut de
*/
function get_headers_php4( $url )
{
$url_info = parse_url( $url );
$fp = fsockopen( $url_info['host'],80,$errno,$errstr,30 );
if ($fp)
{
$head = "HEAD
".$url_info['path']."?".$url_info['query']."
HTTP/1.0\r\n" .
"Host: ".$url_info['host']."\r\n\r\n";
fputs( $fp, $head );
while( !feof($fp ) )
{
$header[] = fgets( $fp, 1024 );
}
return $header;
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.get-headers.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45420
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45420&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45420&report=yes
Search -- http://master.php.net/manage/user-notes.php