Using cURL for a HEAD request
Posted by: Arancaytar
Posted on: 2006-09-27 01:03:00
I can't figure out what I'm doing wrong here. The code block is intended to take the URL contained in $url, send a HEAD request and then print the header that comes back.
For this test, I set $url="http://www.google.com".
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST,"HEAD");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$head=curl_exec($ch);
var_dump($head);
curl_close($ch);
curl_exec only returns true - even though it should return the entire contents since I set RETURNTRANSFER to 1.
Any ideas?