8000 sendContent return as parent. · symfony/symfony@120dfe4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 120dfe4

Browse files
committed
sendContent return as parent.
1 parent bb85161 commit 120dfe4

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class BinaryFileResponse extends Response
2727
{
2828
protected static $trustXSendfileTypeHeader = false;
2929

30+
/**
31+
* @var File
32+
*/
3033
protected $file;
3134
protected $offset;
3235
protected $maxlen;
@@ -179,7 +182,7 @@ public function prepare(Request $request)
179182
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
180183
}
181184

182-
if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) {
185+
if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) {
183186
$this->setProtocolVersion('1.1');
184187
}
185188

@@ -196,17 +199,17 @@ public function prepare(Request $request)
196199
if (false === $path) {
197200
$path = $this->file->getPathname();
198201
}
199-
if (strtolower($type) == 'x-accel-redirect') {
202+
if (strtolower($type) === 'x-accel-redirect') {
200203
// Do X-Accel-Mapping substitutions.
201204
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
202205
foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) {
203206
$mapping = explode('=', $mapping, 2);
204207

205-
if (2 == count($mapping)) {
208+
if (2 === count($mapping)) {
206209
$pathPrefix = trim($mapping[0]);
207210
$location = trim($mapping[1]);
208211

209-
if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) {
212+
if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) {
210213
$path = $location.substr($path, strlen($pathPrefix));
211214
break;
212215
}
@@ -217,7 +220,7 @@ public function prepare(Request $request)
217220
$this->maxlen = 0;
218221
} elseif ($request->headers->has('Range')) {
219222
// Process the range headers.
220-
if (!$request->headers->has('If-Range') || $this->getEtag() == $request->headers->get('If-Range')) {
223+
if (!$request->headers->has('If-Range') || $this->getEtag() === $request->headers->get('If-Range')) {
221224
$range = $request->headers->get('Range');
222225
$fileSize = $this->file->getSize();
223226

@@ -252,17 +255,17 @@ public function prepare(Request $request)
252255

253256
/**
254257
* Sends the file.
258+
*
259+
* {@inheritdoc}
255260
*/
256261
public function sendContent()
257262
{
258263
if (!$this->isSuccessful()) {
259-
parent::sendContent();
260-
261-
return;
264+
return parent::sendContent();
262265
}
263266

264267
if (0 === $this->maxlen) {
265-
return;
268+
return $this;
266269
}
267270

268271
$out = fopen('php://output', 'wb');
@@ -272,6 +275,8 @@ public function sendContent()
272275

273276
fclose($out);
274277
fclose($file);
278+
279+
return $this;
275280
}
276281

277282
/**

0 commit comments

Comments
 (0)
0