Hey, I have the following code which gets returns the headers of a website:
PHP code:
function head
($url)
{
$ch = curl_init
();
curl_setopt
($ch, CURLOPT_URL
, $url);
curl_setopt
($ch, CURLOPT_HEADER
, true);
curl_setopt
($ch, CURLOPT_RETURNTRANSFER
, 1);
curl_setopt
($ch, CURLOPT_FOLLOWLOCATION
, true);
curl_setopt
($ch, CURLOPT_MAXREDIRS
, 7);
curl_setopt
($ch, CURLOPT_USERAGENT
, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt
($ch, CURLOPT_NOBODY
, true);
$output = curl_exec
($ch);
// check for errors
if (curl_errno
($ch))
{
echo curl_error
($ch);
$output = false;
}
curl_close
($ch);
return $output;
}
This works perfectly on my local server, but when I upload it to Dreamhost, it only returns the headers for the first website, and does not follow the location header (
EDIT: the first headers are only shown if I add a [font=courier]echo $output; after the curl_exec line). It also throws this error:
quote:
Originally posted by curl
transfer closed with outstanding read data remaining
Does anyone know what's going on?
Thanks
Sorry for the lack of information. I'm in a hurry now!