Skip to content

Commit fcd0e41

Browse files
committed
Use Filesystem reference to read
1 parent b47b88b commit fcd0e41

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/DocumentRoot.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Amp\Http\Server\StaticContent\Internal\Precondition;
2020
use Amp\Pipeline\Pipeline;
2121
use function Amp\File\filesystem;
22-
use function Amp\File\read;
2322
use function Amp\Http\formatDateHeader;
2423

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

555554
public function setExpiresPeriod(int $seconds): void
556555
{
557-
$this->expiresPeriod = ($seconds < 0) ? 0 : $seconds;
556+
$this->expiresPeriod = \max(0, $seconds);
558557
}
559558

560559
public function loadMimeFileTypes(string $mimeFile): void
561560
{
562561
$mimeFile = \str_replace('\\', '/', $mimeFile);
563-
$contents = read($mimeFile);
564-
if ($contents === false) {
565-
throw new \Exception(
566-
"Failed loading mime associations from file {$mimeFile}"
567-
);
568-
}
562+
$contents = $this->filesystem->read($mimeFile);
569563

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

0 commit comments

Comments
 (0)