This commit is contained in:
2021-03-09 19:20:36 +08:00
parent 2f61803469
commit 89d3f53fde
+13 -27
View File
@@ -291,36 +291,22 @@ class Response extends HttpService
{
$open = fopen($path, 'r');
$name = explode(DIRECTORY_SEPARATOR, $path);
$stat = fstat($open);
$this->response->setHeader('Content-Type', 'model/gltf-binary');
$this->response->setHeader('accept-ranges', 'bytes');
$this->response->setHeader('age', '0');
$this->response->setHeader('cache-control', 'max-age=600');
$this->response->setHeader('vary', 'Accept-Encoding');
$this->response->setHeader('via', '1.1 varnish');
// $this->response->setHeader('content-encoding', 'gzip');
// $this->response->setHeader('Content-Disposition', ' attachment; filename="' . end($name) . '"');
$this->response->gzip(5);
$this->response->sendfile($path);
//
// while ($file = fread($open, $limit)) {
// $this->response->write($file);
// fseek($open, $offset);
// if ($sleep > 0) {
// sleep($sleep);
// }
// if ($offset >= $stat['size']) {
// break;
// }
// $offset += $limit;
// }
//
// $this->response->end();
$this->headers(null);
while ($file = fread($open, $limit)) {
$this->response->write($file);
fseek($open, $offset);
if ($sleep > 0) {
sleep($sleep);
}
if ($offset >= $stat['size']) {
break;
}
$offset += $limit;
}
$this->response->end();
$this->response = null;
return '';
}