Page 1 of 1

CURLOPT_RANGE

Posted: Wed Jul 28, 2010 1:49 am
by infomamun
Does anybody know why CURLOPT_RANGE is not working? It is returning the whole page instead lines of predefined length. Any solution there?

Re: CURLOPT_RANGE

Posted: Fri Jul 30, 2010 10:07 pm
by infomamun
Any cURL expert please reply. :roll:

Re: CURLOPT_RANGE

Posted: Sat Jul 31, 2010 6:30 am
by Bind
My understanding of SETOPT_RANGE is that it does NOT return LINES of predefined length in a single file, but a byte-range data chunk of the data contained in said file, with predefined start and stop positions (in bytes), regardless of lines.

In simple terms SETOPT_RANGE does not consider lines at all.

For instance, CURL_SETOPT($clink,CURLOPT_RANGE,"0-999"); would return the first 1000 bytes of the document regardless of length of the individual lines of that document. Now depending on the file, that could be one line or 1000 lines.

If you wish to parse by individual line and line length, you would need to import the document, then use php to parse by line and/or line length.

It's hard to tell exactly where your problems are ocurring, so if I misunderstood your post, please post some source code so we can see what you are doing.

Re: CURLOPT_RANGE

Posted: Sat Jul 31, 2010 8:51 pm
by infomamun
Thanks bind For your reply. Actually I told about bytes reading, but mistakenly wrote as line. It cant return bytes I specify, instead returns the whole page. Only when I used that code at first time, that time it returned perfectly. But after that, I dont know why, it could not return the byte wise output, returning the whole page and even for the same url that I found correct output at first.

I used below code. Would you please check it for me if there is an error:

<?
$url = 'http://www.dsebd.org';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RANGE, "100-1000");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
curl_close($ch);
echo $content;
?>