Only set the header if the node exists and in case the request is a GET
This commit is contained in:
parent
2cad9d2b8c
commit
703f3551dc
1 changed files with 8 additions and 3 deletions
|
@ -110,10 +110,15 @@ class Server {
|
|||
|
||||
// Serve all files with an Content-Disposition of type "attachment"
|
||||
$this->server->on('beforeMethod', function (RequestInterface $requestInterface, ResponseInterface $responseInterface) {
|
||||
$node = $this->server->tree->getNodeForPath($requestInterface->getPath());
|
||||
if (($node instanceof IFile)) {
|
||||
$responseInterface->addHeader('Content-Disposition', 'attachment');
|
||||
if ($requestInterface->getMethod() === 'GET') {
|
||||
$path = $requestInterface->getPath();
|
||||
if ($this->server->tree->nodeExists($path)) {
|
||||
$node = $this->server->tree->getNodeForPath($path);
|
||||
if (($node instanceof IFile)) {
|
||||
$responseInterface->addHeader('Content-Disposition', 'attachment');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// wait with registering these until auth is handled and the filesystem is setup
|
||||
|
|
Loading…
Reference in a new issue