sendContent return as parent.
This commit is contained in:
parent
bb85161de9
commit
120dfe48a6
@ -27,6 +27,9 @@ class BinaryFileResponse extends Response
|
|||||||
{
|
{
|
||||||
protected static $trustXSendfileTypeHeader = false;
|
protected static $trustXSendfileTypeHeader = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var File
|
||||||
|
*/
|
||||||
protected $file;
|
protected $file;
|
||||||
protected $offset;
|
protected $offset;
|
||||||
protected $maxlen;
|
protected $maxlen;
|
||||||
@ -179,7 +182,7 @@ class BinaryFileResponse extends Response
|
|||||||
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
|
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) {
|
if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) {
|
||||||
$this->setProtocolVersion('1.1');
|
$this->setProtocolVersion('1.1');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,17 +199,17 @@ class BinaryFileResponse extends Response
|
|||||||
if (false === $path) {
|
if (false === $path) {
|
||||||
$path = $this->file->getPathname();
|
$path = $this->file->getPathname();
|
||||||
}
|
}
|
||||||
if (strtolower($type) == 'x-accel-redirect') {
|
if (strtolower($type) === 'x-accel-redirect') {
|
||||||
// Do X-Accel-Mapping substitutions.
|
// Do X-Accel-Mapping substitutions.
|
||||||
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
|
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
|
||||||
foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) {
|
foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) {
|
||||||
$mapping = explode('=', $mapping, 2);
|
$mapping = explode('=', $mapping, 2);
|
||||||
|
|
||||||
if (2 == count($mapping)) {
|
if (2 === count($mapping)) {
|
||||||
$pathPrefix = trim($mapping[0]);
|
$pathPrefix = trim($mapping[0]);
|
||||||
$location = trim($mapping[1]);
|
$location = trim($mapping[1]);
|
||||||
|
|
||||||
if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) {
|
if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) {
|
||||||
$path = $location.substr($path, strlen($pathPrefix));
|
$path = $location.substr($path, strlen($pathPrefix));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -217,7 +220,7 @@ class BinaryFileResponse extends Response
|
|||||||
$this->maxlen = 0;
|
$this->maxlen = 0;
|
||||||
} elseif ($request->headers->has('Range')) {
|
} elseif ($request->headers->has('Range')) {
|
||||||
// Process the range headers.
|
// Process the range headers.
|
||||||
if (!$request->headers->has('If-Range') || $this->getEtag() == $request->headers->get('If-Range')) {
|
if (!$request->headers->has('If-Range') || $this->getEtag() === $request->headers->get('If-Range')) {
|
||||||
$range = $request->headers->get('Range');
|
$range = $request->headers->get('Range');
|
||||||
$fileSize = $this->file->getSize();
|
$fileSize = $this->file->getSize();
|
||||||
|
|
||||||
@ -252,17 +255,17 @@ class BinaryFileResponse extends Response
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the file.
|
* Sends the file.
|
||||||
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function sendContent()
|
public function sendContent()
|
||||||
{
|
{
|
||||||
if (!$this->isSuccessful()) {
|
if (!$this->isSuccessful()) {
|
||||||
parent::sendContent();
|
return parent::sendContent();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === $this->maxlen) {
|
if (0 === $this->maxlen) {
|
||||||
return;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = fopen('php://output', 'wb');
|
$out = fopen('php://output', 'wb');
|
||||||
@ -272,6 +275,8 @@ class BinaryFileResponse extends Response
|
|||||||
|
|
||||||
fclose($out);
|
fclose($out);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user