Question

I'm using PHP function virtual() for sending files by Apache 2.2 (it works faster than readfile()) and I can check user access permissions.

But is there any way to add continuous download support, with HTTP_RANGE?

I have tried things like this

if(isset($_SERVER['HTTP_RANGE'])) { 
        list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']); 
        str_replace($range, "-", $range); 
        $size2=$size-1; 
        $new_length=$size-$range; 
        header("HTTP/1.1 206 Partial Content"); 
        header("Content-Length: $new_length"); 
        header("Content-Range: bytes $range$size2/$size"); 
        apache_setenv('HTTP_RANGE', $_SERVER['HTTP_RANGE']);
    } else { 
        $size2=$size-1; 
        header("Content-Range: bytes 0-$size2/$size"); 
        header("Content-Length: ".$size); 
} 

So web-client was downloaded files like if HTTP_RANGE works, but in real Apache just sends always the same file-ranges like: if client ask 4000-6000 bytes, Apache sends 0-2000 and etc, so files was broken.

I think that there is some way to do it using apache_setenv, but can't find in Google any suggestion about that.

Was it helpful?

Solution

Try to use xfilesend module for Apache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top