private function respondWithLookup(string $realPath, string $reqPath, Request $request, Response $response) : \Generator
{
// We don't catch any potential exceptions from this yield because they represent
// a legitimate error from some sort of disk failure. Just let them bubble up to
// the server where they'll turn into a 500 response.
$fileInfo = (yield from $this->lookup($realPath));
// Specifically use the request path to reference this file in the
// cache because the file entry path may differ if it's reflecting
// a directory index file.
if ($this->cacheEntryCount < $this->cacheEntryMaxCount) {
$this->cacheEntryCount++;
$this->cache[$reqPath] = $fileInfo;
$this->cacheTimeouts[$reqPath] = $this->now + $this->cacheEntryTtl;
}
$result = $this->respond($fileInfo, $request, $response);
if ($result instanceof \Generator) {
yield from $result;
}
}