Skip to content

Commit 62d1a43

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: [Finder] Fix using `==` as default operator in `DateComparator` [HttpFoundation] Avoid mime type guess with temp files in `BinaryFileResponse` choose the correctly cased class name for the MariaDB platform
2 parents e88a66c + b5567e7 commit 62d1a43

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

BinaryFileResponse.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ public function prepare(Request $request): static
189189
}
190190

191191
if (!$this->headers->has('Content-Type')) {
192-
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
192+
$mimeType = null;
193+
if (!$this->tempFileObject) {
194+
$mimeType = $this->file->getMimeType();
195+
}
196+
197+
$this->headers->set('Content-Type', $mimeType ?: 'application/octet-stream');
193198
}
194199

195200
parent::prepare($request);

Tests/BinaryFileResponseTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,15 @@ public function testSetChunkSizeTooSmall()
468468

469469
$response->setChunkSize(0);
470470
}
471+
472+
public function testCreateFromTemporaryFileWithoutMimeType()
473+
{
474+
$file = new \SplTempFileObject();
475+
$file->fwrite('foo,bar');
476+
477+
$response = new BinaryFileResponse($file);
478+
$response->prepare(new Request());
479+
480+
$this->assertSame('application/octet-stream', $response->headers->get('Content-Type'));
481+
}
471482
}

0 commit comments

Comments
 (0)