Envío de archivos mediante la función Apache y PHP virtual () con soporte HTTP_RANGE
-
28-10-2019 - |
Pregunta
Estoy usando la función de PHP virtual () para enviar archivos mediante Apache 2.2 (funciona más rápido que
¿Pero hay alguna forma de agregar soporte de descarga continua con HTTP_RANGE?
He probado cosas como esta
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);
}
Entonces, el cliente web descargó archivos como si HTTP_RANGE funciona, pero en Apache real solo envía siempre los mismos rangos de archivos como: si el cliente solicita 4000-6000 bytes, Apache envía 0-2000 y etc., por lo que los archivos estaban dañados.
Creo que hay alguna forma de hacerlo usando apache_setenv, pero no encuentro en Google ninguna sugerencia al respecto.
Solución
Intente utilizar el módulo xfilesend para Apache.