Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


PHP Mutli Range Resume Supported segmented downloading
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

PHP Mutli Range Resume Supported segmented downloading

noamannoaman Member
edited October 2015 in Help

Hi
I am using free download manager to test multi thread downloading with resume support.The programming language used as you can see is PHP.

if(isset($_SERVER['HTTP_RANGE']))
{
// Resume requested
preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches);
$range=explode('-', $_SERVER['HTTP_RANGE'], 2);
$items=count($range);
if($items != 2){
header('HTTP/1.1 416 Requested Range Not Satisfiable');
die(); }
$offset = $range[0];
$length = $range[1] - $offset;
$content_length=$length-1;
header("HTTP/1.1 206 Partial Content");
header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $filesize);
$current_position=$offset;
$next_postion=(int)$range[1];
header("Content-Length: ".$content_length);
$chunk="SOme_aribitray_data";
echo $chunk;
die();
}

The problem is that it is not allowing me to create segments or parts.What cany be the reason?
I think the error is in this portion of the code ....

Also How do you debug this kind of PHP code ?
I have installed ModHeader Chrome Plugin.But can anybody recommend some dev tools for http protocol and headers

Thanx in advance

Comments

  • NixtrenNixtren Member
    edited October 2015

    Fiddler2 is an HTTP Proxy used for HTTP debugging. One of the essentials tools in my opinion. Only available for Windows though (maybe you can run it under Mono if your computer is a Linux one).

  • @nixtren
    Thanx for the tool .I will look into that

Sign In or Register to comment.