|
5 | 5 |
|
6 | 6 | use ADmad\Glide\Exception\ResponseException; |
7 | 7 | use ADmad\Glide\Exception\SignatureException; |
8 | | -use ADmad\Glide\Responses\PsrResponseFactory; |
| 8 | +use ADmad\Glide\Response\PsrResponseFactory; |
| 9 | +use Cake\Core\Configure; |
9 | 10 | use Cake\Core\InstanceConfigTrait; |
10 | 11 | use Cake\Event\EventDispatcherInterface; |
11 | 12 | use Cake\Event\EventDispatcherTrait; |
@@ -180,7 +181,7 @@ protected function _checkModified(ServerRequestInterface $request, Server $serve |
180 | 181 | try { |
181 | 182 | /** @var int|string|false $modifiedTime */ |
182 | 183 | $modifiedTime = $server->getSource() |
183 | | - ->getTimestamp($server->getSourcePath($this->_path)); |
| 184 | + ->lastModified($server->getSourcePath($this->_path)); |
184 | 185 | } catch (Exception $exception) { |
185 | 186 | return $this->_handleException($request, $exception); |
186 | 187 | } |
@@ -254,13 +255,10 @@ protected function _passThrough(ServerRequestInterface $request, Server $server) |
254 | 255 | $path = $server->getSourcePath($this->_path); |
255 | 256 |
|
256 | 257 | $resource = $source->readStream($path); |
257 | | - if ($resource === false) { |
258 | | - throw new ResponseException(); |
259 | | - } |
260 | 258 | $stream = new Stream($resource); |
261 | 259 |
|
262 | | - $contentType = $source->getMimetype($path); |
263 | | - $contentLength = $source->getSize($path); |
| 260 | + $contentType = $source->mimeType($path); |
| 261 | + $contentLength = $source->fileSize($path); |
264 | 262 |
|
265 | 263 | /** @psalm-suppress PossiblyFalseArgument */ |
266 | 264 | return (new Response())->withBody($stream) |
@@ -345,6 +343,10 @@ protected function _handleException(ServerRequestInterface $request, $exception) |
345 | 343 | return $result; |
346 | 344 | } |
347 | 345 |
|
| 346 | + if (Configure::read('debug')) { |
| 347 | + throw $exception; |
| 348 | + } |
| 349 | + |
348 | 350 | throw new ResponseException(null, null, $exception); |
349 | 351 | } |
350 | 352 | } |
0 commit comments