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
126126 */
127127 public function setAutoLastModified (): static
128128 {
129- $ this ->setLastModified (\DateTimeImmutable::createFromFormat ('U ' , $ this ->file ->getMTime ()));
129+ $ this ->setLastModified (\DateTimeImmutable::createFromFormat ('U ' , $ this ->tempFileObject ? time () : $ this -> file ->getMTime ()));
130130
131131 return $ this ;
132132 }
@@ -197,7 +197,9 @@ public function prepare(Request $request): static
197197 $ this ->offset = 0 ;
198198 $ this ->maxlen = -1 ;
199199
200- if (false === $ fileSize = $ this ->file ->getSize ()) {
200+ if ($ this ->tempFileObject ) {
201+ $ fileSize = $ this ->tempFileObject ->fstat ()['size ' ];
202+ } elseif (false === $ fileSize = $ this ->file ->getSize ()) {
201203 return $ this ;
202204 }
203205 $ this ->headers ->remove ('Transfer-Encoding ' );
Original file line number Diff line number Diff line change @@ -451,6 +451,9 @@ public function testCreateFromTemporaryFile()
451451 $ this ->assertEquals ('attachment; filename=temp ' , $ response ->headers ->get ('Content-Disposition ' ));
452452
453453 ob_start ();
454+ $ response ->setAutoLastModified ();
455+ $ response ->prepare (new Request ());
456+ $ this ->assertSame ('7 ' , $ response ->headers ->get ('Content-Length ' ));
454457 $ response ->sendContent ();
455458 $ string = ob_get_clean ();
456459 $ this ->assertSame ('foo,bar ' , $ string );
You can’t perform that action at this time.
0 commit comments