getfc() now returns headers too

This commit is contained in:
pezcurrel 2022-12-08 00:08:36 +01:00
parent 6c2672ea00
commit 2729e717c9

View file

@ -11,7 +11,11 @@ function getfc($url,$timeout,$headers=[]) {
curl_setopt($curli,CURLOPT_TIMEOUT,$timeout);
curl_setopt($curli,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($curli,CURLOPT_HTTPHEADER,$headers);
curl_setopt($curli,CURLOPT_HEADER,true);
$cont=curl_exec($curli);
$headers_sz=curl_getinfo($curli,CURLINFO_HEADER_SIZE);
$headers=substr($cont,0,$headers_sz);
$cont=substr($cont,$headers_sz);
$emsg=false;
$cerrno=curl_errno($curli);
if ($cerrno) {
@ -24,7 +28,7 @@ function getfc($url,$timeout,$headers=[]) {
$emsg='unknown';
}
curl_close($curli);
return(array('cont'=>$cont,'emsg'=>$emsg));
return(['cont'=>$cont,'headers'=>$headers,'emsg'=>$emsg]);
}
?>