Dirty hack to disable dav plugins on public calendar urls

This commit is contained in:
Thomas Citharel 2016-07-11 16:10:25 +02:00 committed by Lukas Reschke
parent 00dc157b19
commit 994001c480
No known key found for this signature in database
GPG key ID: B9F6980CF6E759B1

View file

@ -91,6 +91,7 @@ class PublishPlugin extends ServerPlugin
$this->server->on('method:POST', [$this, 'httpPost']);
$this->server->on('propFind', [$this, 'propFind']);
$this->server->on('method:OPTIONS', [$this, 'httpOptions'], 5);
}
public function propFind(PropFind $propFind, INode $node)
@ -209,4 +210,23 @@ class PublishPlugin extends ServerPlugin
}
}
public function httpOptions(RequestInterface $request, ResponseInterface $response) {
if ($request->getPath() == 'public-calendars') {
$methods = $this->server->getAllowedMethods($request->getPath());
$response->setHeader('Allow', strtoupper(implode(', ', $methods)));
$features = ['1', '3', 'extended-mkcol'];
$response->setHeader('DAV', implode(', ', $features));
$response->setHeader('MS-Author-Via', 'DAV');
$response->setHeader('Accept-Ranges', 'bytes');
$response->setHeader('Content-Length', '0');
$response->setStatus(200);
// Sending back false will interupt the event chain and tell the server
// we've handled this method.
return false;
}
}
}