I've written some code to get a file via curl. I only want the headers and not the actual file itself
$info = curl_init() or die('error 1');
curl_setopt($info, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($info, CURLOPT_PORT , 8089);
curl_setopt($info, CURLOPT_URL, $url);
curl_setopt($info, CURLOPT_HEADER,true);
curl_setopt($info, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($info, CURLOPT_NOBODY, true);
//curl_setopt($info, CURLOPT_SSL_VERIFYPEER, 0);
curl_exec($info);
if(!curl_errno($info)){
$response = curl_getinfo($info);
echo "<pre>";
print_r(get_headers($response));
echo "</pre>";
}else{
echo "error!";
echo "<br>" . curl_error($info);
}
However the response returned by this doesn't contain any of the information that should be in a header - e.g filename
array(26) {
["url"]=>
string(55) "https://www.filepicker.io/api/file/CjDfxG0WSmGiY3O2eKDE"
["content_type"]=>
string(9) "image/png"
["http_code"]=>
int(200)
["header_size"]=>
int(840)
["request_size"]=>
int(86)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(1.578048)
["namelookup_time"]=>
float(0.000494)
["connect_time"]=>
float(0.026931)
["pretransfer_time"]=>
float(0.13615)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(965985)
["upload_content_length"]=>
float(0)
["starttransfer_time"]=>
float(1.578002)
["redirect_time"]=>
float(0)
["certinfo"]=>
array(0) {
}
["primary_ip"]=>
string(11) "79.125.4.68"
["primary_port"]=>
int(443)
["local_ip"]=>
string(11) "192.168.0.9"
["local_port"]=>
int(53950)
["redirect_url"]=>
string(0) ""
}
So how can I get the actual header itself?