@@ -27,6 +27,9 @@ class BinaryFileResponse extends Response
27
27
{
28
28
protected static $ trustXSendfileTypeHeader = false ;
29
29
30
+ /**
31
+ * @var File
32
+ */
30
33
protected $ file ;
31
34
protected $ offset ;
32
35
protected $ maxlen ;
@@ -179,7 +182,7 @@ public function prepare(Request $request)
179
182
$ this ->headers ->set ('Content-Type ' , $ this ->file ->getMimeType () ?: 'application/octet-stream ' );
180
183
}
181
184
182
- if ('HTTP/1.0 ' != $ request ->server ->get ('SERVER_PROTOCOL ' )) {
185
+ if ('HTTP/1.0 ' !== $ request ->server ->get ('SERVER_PROTOCOL ' )) {
183
186
$ this ->setProtocolVersion ('1.1 ' );
184
187
}
185
188
@@ -196,17 +199,17 @@ public function prepare(Request $request)
196
199
if (false === $ path ) {
197
200
$ path = $ this ->file ->getPathname ();
198
201
}
199
- if (strtolower ($ type ) == 'x-accel-redirect ' ) {
202
+ if (strtolower ($ type ) === 'x-accel-redirect ' ) {
200
203
// Do X-Accel-Mapping substitutions.
201
204
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
202
205
foreach (explode (', ' , $ request ->headers ->get ('X-Accel-Mapping ' , '' )) as $ mapping ) {
203
206
$ mapping = explode ('= ' , $ mapping , 2 );
204
207
205
- if (2 == count ($ mapping )) {
208
+ if (2 === count ($ mapping )) {
206
209
$ pathPrefix = trim ($ mapping [0 ]);
207
210
$ location = trim ($ mapping [1 ]);
208
211
209
- if (substr ($ path , 0 , strlen ($ pathPrefix )) == $ pathPrefix ) {
212
+ if (substr ($ path , 0 , strlen ($ pathPrefix )) === $ pathPrefix ) {
210
213
$ path = $ location .substr ($ path , strlen ($ pathPrefix ));
211
214
break ;
212
215
}
@@ -217,7 +220,7 @@ public function prepare(Request $request)
217
220
$ this ->maxlen = 0 ;
218
221
} elseif ($ request ->headers ->has ('Range ' )) {
219
222
// 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 ' )) {
221
224
$ range = $ request ->headers ->get ('Range ' );
222
225
$ fileSize = $ this ->file ->getSize ();
223
226
@@ -252,17 +255,17 @@ public function prepare(Request $request)
252
255
253
256
/**
254
257
* Sends the file.
258
+ *
259
+ * {@inheritdoc}
255
260
*/
256
261
public function sendContent ()
257
262
{
258
263
if (!$ this ->isSuccessful ()) {
259
- parent ::sendContent ();
260
-
261
- return ;
264
+ return parent ::sendContent ();
262
265
}
263
266
264
267
if (0 === $ this ->maxlen ) {
265
- return ;
268
+ return $ this ;
266
269
}
267
270
268
271
$ out = fopen ('php://output ' , 'wb ' );
@@ -272,6 +275,8 @@ public function sendContent()
272
275
273
276
fclose ($ out );
274
277
fclose ($ file );
278
+
279
+ return $ this ;
275
280
}
276
281
277
282
/**
0 commit comments