CURLOPT_RANGE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
infomamun
Forum Contributor
Posts: 102
Joined: Mon Dec 28, 2009 7:48 pm

CURLOPT_RANGE

Post 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?
infomamun
Forum Contributor
Posts: 102
Joined: Mon Dec 28, 2009 7:48 pm

Re: CURLOPT_RANGE

Post by infomamun »

Any cURL expert please reply. :roll:
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: CURLOPT_RANGE

Post 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.
Last edited by Bind on Sun Aug 01, 2010 6:10 am, edited 1 time in total.
infomamun
Forum Contributor
Posts: 102
Joined: Mon Dec 28, 2009 7:48 pm

Re: CURLOPT_RANGE

Post 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;
?>
Post Reply