Skip to content

Commit

Permalink
Use Filesystem reference to read
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Aug 20, 2023
1 parent b47b88b commit fcd0e41
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/DocumentRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Amp\Http\Server\StaticContent\Internal\Precondition;
use Amp\Pipeline\Pipeline;
use function Amp\File\filesystem;
use function Amp\File\read;
use function Amp\Http\formatDateHeader;

final class DocumentRoot implements RequestHandler
Expand Down Expand Up @@ -554,18 +553,13 @@ public function setUseEtagInode(bool $useInode): void

public function setExpiresPeriod(int $seconds): void
{
$this->expiresPeriod = ($seconds < 0) ? 0 : $seconds;
$this->expiresPeriod = \max(0, $seconds);
}

public function loadMimeFileTypes(string $mimeFile): void
{
$mimeFile = \str_replace('\\', '/', $mimeFile);
$contents = read($mimeFile);
if ($contents === false) {
throw new \Exception(
"Failed loading mime associations from file {$mimeFile}"
);
}
$contents = $this->filesystem->read($mimeFile);

if (!\preg_match_all('#\s*([a-z0-9]+)\s+([a-z0-9\-]+/[a-z0-9\-]+(?:\+[a-z0-9\-]+)?)#i', $contents, $matches)) {
throw new \Exception(
Expand Down

0 comments on commit fcd0e41

Please sign in to comment.