getfc() now returns headers too
This commit is contained in:
parent
6c2672ea00
commit
2729e717c9
1 changed files with 5 additions and 1 deletions
|
@ -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]);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue