File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ public function setChunkSize(int $chunkSize): static
126
126
*/
127
127
public function setAutoLastModified (): static
128
128
{
129
- $ this ->setLastModified (\DateTimeImmutable::createFromFormat ('U ' , $ this ->file ->getMTime ()));
129
+ $ this ->setLastModified (\DateTimeImmutable::createFromFormat ('U ' , $ this ->tempFileObject ? time () : $ this -> file ->getMTime ()));
130
130
131
131
return $ this ;
132
132
}
@@ -197,7 +197,9 @@ public function prepare(Request $request): static
197
197
$ this ->offset = 0 ;
198
198
$ this ->maxlen = -1 ;
199
199
200
- if (false === $ fileSize = $ this ->file ->getSize ()) {
200
+ if ($ this ->tempFileObject ) {
201
+ $ fileSize = $ this ->tempFileObject ->fstat ()['size ' ];
202
+ } elseif (false === $ fileSize = $ this ->file ->getSize ()) {
201
203
return $ this ;
202
204
}
203
205
$ this ->headers ->remove ('Transfer-Encoding ' );
Original file line number Diff line number Diff line change @@ -451,6 +451,9 @@ public function testCreateFromTemporaryFile()
451
451
$ this ->assertEquals ('attachment; filename=temp ' , $ response ->headers ->get ('Content-Disposition ' ));
452
452
453
453
ob_start ();
454
+ $ response ->setAutoLastModified ();
455
+ $ response ->prepare (new Request ());
456
+ $ this ->assertSame ('7 ' , $ response ->headers ->get ('Content-Length ' ));
454
457
$ response ->sendContent ();
455
458
$ string = ob_get_clean ();
456
459
$ this ->assertSame ('foo,bar ' , $ string );
You can’t perform that action at this time.
0 commit comments