use CURL with HTTP_RANGE header

Hi
Last night I was working with curl extension to see if there is anything so that I can download remote contents with from specific range. For example I want to download a page from offset 0 to 999, that means first 1000 byte. Or a zip file from offset 1000 to 3000, which means 2000 byte starting from 1000 byte offset. If You can do this, you can easily develop remote down loader with resume support.

Finally I have found that there is a option named CURLOPT_RANGE by which you can specify HTTP_RANGE. Lets take a look at the following code which download first 1000 byte from http://www.phpxperts.net/SmartyCheatSheet.pdf file.

<?
$curl = curl_init("http://www.phpxperts.net/SmartyCheatSheet.pdf");
curl_setopt($curl, CURLOPT_RANGE, "0-999");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl);
echo $content;
?>

well, this is the process. I hope many of you will find this useful.