Skip to content

Commit

Permalink
Fixed Content-Type header parsing in `ResourceFactory::getResourceF…
Browse files Browse the repository at this point in the history
…romUrl()`
  • Loading branch information
tg666 committed Mar 20, 2024
1 parent 59b9832 commit 578ec16
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Resource/ResourceFactory.php
Expand Up @@ -10,8 +10,10 @@
use SixtyEightPublishers\FileStorage\Exception\FileNotFoundException;
use SixtyEightPublishers\FileStorage\Exception\FilesystemException;
use SixtyEightPublishers\FileStorage\PathInfoInterface;
use function array_shift;
use function error_clear_last;
use function error_get_last;
use function explode;
use function file_exists;
use function filter_var;
use function fopen;
Expand Down Expand Up @@ -129,10 +131,21 @@ private function getResourceFromUrl(PathInfoInterface $pathInfo, string $url): R
pathInfo: $pathInfo,
source: $source,
mimeType: function () use ($headers): ?string {
return $this->getHeaderValue(
$contentTypeHeader = $this->getHeaderValue(
headers: $headers,
name: 'Content-Type',
);

if (null === $contentTypeHeader) {
return null;
}

$parts = explode(
separator: ';',
string: $contentTypeHeader,
);

return array_shift($parts);
},
filesize: function () use ($headers): ?int {
$filesize = $this->getHeaderValue(
Expand Down

0 comments on commit 578ec16

Please sign in to comment.