CURLOPT_RANGE
Moderator: General Moderators
CURLOPT_RANGE
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
Any cURL expert please reply. 
Re: CURLOPT_RANGE
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.
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.
Last edited by Bind on Sun Aug 01, 2010 6:10 am, edited 1 time in total.
Re: CURLOPT_RANGE
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;
?>
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;
?>