Added one line to discard from the top of the headers possible “HTTP/(version) 100 Continue” and the empty lines that may follow

This commit is contained in:
pezcurrel 2024-10-25 00:13:37 +02:00
parent 7d931d097b
commit 53929b069e

View file

@ -78,6 +78,8 @@ function curl($url,$napid=null,$headers=null,$postdata=null,$conntimeout=null,$f
$gheaders=substr($res,0,$gheaders_sz-4);// "-4" accounts for the 2 "\r\n" that separates headers from body
// echo "{$gheaders}\n";
$gheaders=explode("\r\n",$gheaders);
// the line below is needed to discard from the top of the headers possible "HTTP/(version) 100 Continue" and the empty lines that may follow
while (trim($gheaders[0])=='' || preg_match('#^HTTP/\d+\.\d+\s+100\s+#',$gheaders[0])===1) array_shift($gheaders);
$res=substr($res,$gheaders_sz);
$httpcode=preg_replace('#^\S+\s+(\d+).*$#','$1',$gheaders[0]);
if (!is_null($napid)) {