Re: [PHP] range header in curl?

2010-11-21 Thread shiplu
On Mon, Nov 22, 2010 at 5:05 AM, Tontonq Tontonq  wrote:

> hi im downloading files from h0tf1le as a premium user by curl i want to do
> something like streaming i want it resend to user what it got from server
> i couldnt find any resource about curl and streaming the executed source
> so i did by the Range header but sometimes i see files are corrupted i
> check
> the logs
>
> GET
>
> http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
> User-Agent:
> Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
> Gecko/20100115 Firefox/3.6
> Host: s137.hotfile.com
> Pragma: no-cache
> Accept: */*
> Connection: Keep-Alive
> Range: bytes=1-2
>
> i only get 1 byte for learn length
>

Not sure why your are getting 1 byte. You should get 2 bytes. Is the size of
pimp.rar 2 bytes? In that case first 2 byte will returned by bytes=0-1 range
specifier instead of bytes=1-2

Check this spec out
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35

May be this will help you.


-- 
Shiplu Mokaddim
http://talk.cmyweb.net


Re: [PHP] range header in curl?

2010-11-21 Thread Michael Shadle
Is range the right header to be sending? I thought it was something else.

Also I believe there is a curl_setopt option for range... Look at php.net's 
predefined constants for the curl modul

On Nov 21, 2010, at 3:05 PM, Tontonq Tontonq  wrote:

> hi im downloading files from h0tf1le as a premium user by curl i want to do
> something like streaming i want it resend to user what it got from server
> i couldnt find any resource about curl and streaming the executed source
> so i did by the Range header but sometimes i see files are corrupted i check
> the logs
> 
> GET
> http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
> Gecko/20100115 Firefox/3.6
> Host: s137.hotfile.com
> Pragma: no-cache
> Accept: */*
> Connection: Keep-Alive
> Range: bytes=1-2
> 
> i only get 1 byte for learn length
> 
> 
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 1-2/5781810
> 
> i see the range
> 
> request:Range: bytes=0-2097152
> response:
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 0-2097152/5781810
> Connection: close
> 
> request:Range: bytes=2097152-4194304
> response:
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 2097152-4194304/5781810
> Connection: close
> 
> request:Range: bytes=4194304-5781810
> 
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 4194304-5781810/5781810
> Connection: close
> 
> 
> i can not see any error do you?
> 
> and this is a part of it
> 
> 
> 
> $kackb=arasi('Content-Range: bytes 1-2/','
> ',$cikti);
> $bytes=(int)$kackb;
> $infocuk=curl_getinfo($ch);
> $sabiturl=$infocuk["url"];
> curl_close($ch);
> $sinir*=1024;
> $kackez=$bytes/$sinir;
> 
> 
> for($i=0;$i<=$kackez;$i++)
> {
> $bsinir=$i*$sinir;
> $ssinir+=$sinir;
> if($bytes<$ssinir) { $ssinir=$bytes; }
> $header = array("Range: bytes=$bsinir-$ssinir");
> $ch = curl_init();
> curl_setopt($ch , CURLOPT_URL, $sabiturl);
> curl_setopt($ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT
> 5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6');
> curl_setopt($ch , CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');
> curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
> curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
> if($proxy) { curl_setopt($ch , CURLOPT_PROXY, $proxy); }
> curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header );
> curl_setopt($ch , CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1);
> $cikti = curl_exec($ch);
> echo $cikti;
> 
> }

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] range header in curl?

2010-11-21 Thread Tontonq Tontonq
hi im downloading files from h0tf1le as a premium user by curl i want to do
something like streaming i want it resend to user what it got from server
i couldnt find any resource about curl and streaming the executed source
so i did by the Range header but sometimes i see files are corrupted i check
the logs

GET
http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
Gecko/20100115 Firefox/3.6
Host: s137.hotfile.com
Pragma: no-cache
Accept: */*
Connection: Keep-Alive
Range: bytes=1-2

i only get 1 byte for learn length


Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 1-2/5781810

i see the range

request:Range: bytes=0-2097152
response:
Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 0-2097152/5781810
Connection: close

request:Range: bytes=2097152-4194304
response:
Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 2097152-4194304/5781810
Connection: close

request:Range: bytes=4194304-5781810

Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 4194304-5781810/5781810
Connection: close


i can not see any error do you?

and this is a part of it



$kackb=arasi('Content-Range: bytes 1-2/','
',$cikti);
$bytes=(int)$kackb;
$infocuk=curl_getinfo($ch);
$sabiturl=$infocuk["url"];
curl_close($ch);
$sinir*=1024;
$kackez=$bytes/$sinir;


for($i=0;$i<=$kackez;$i++)
{
$bsinir=$i*$sinir;
$ssinir+=$sinir;
if($bytes<$ssinir) { $ssinir=$bytes; }
$header = array("Range: bytes=$bsinir-$ssinir");
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, $sabiturl);
curl_setopt($ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT
5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6');
curl_setopt($ch , CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');
curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
if($proxy) { curl_setopt($ch , CURLOPT_PROXY, $proxy); }
curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header );
curl_setopt($ch , CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1);
$cikti = curl_exec($ch);
echo $cikti;

}