Link to home
Start Free TrialLog in
Avatar of kuist
kuist

asked on

curl


Here I'm using curl to verify a list of link (avi/mpg) to be sure there is not 404.

what I do is

          $ch = curl_init ($url);
               curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
               curl_setopt($ch, CURLOPT_HEADER, 1);
               $result2 = curl_exec ($ch);
          curl_close ($ch);

          print $result2;

and verify that they have the Content-Type: video/x-msvideo header

but how to stop curl from downloading the whole avi/mpg ?!
I just want the headers
Avatar of higijj
higijj

Use the curl_opt like

curl_setopt($ch, CURLOPT_NOBODY, 1);


Regards,
Avatar of kuist

ASKER

yeah.. but it takes for ever to check like 10 of them!

maybe there is a way to do it with socket function?!

Please advise!
ASKER CERTIFIED SOLUTION
Avatar of dkjariwala
dkjariwala

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kuist

ASKER

what's the 8192 for?

it's on the 4th line ..

how do I say to just collect the first 4 lines ?
8192 is number of bytes, its 8k basically. You can keep it to say 4096 - 4k.

It means data will be read in 4k chunk from socket.

JD
Avatar of kuist

ASKER

and 4k is enough to cover the headers ?

how do I tell to read just the first 4k ?
replace existing $line...with

$line = fgets($fp,4096); //it should read 4k.

And yeah it will suffice though try and test it. thats the best way !!

JD