Skip to content

Commit

Permalink
fix: options call
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapi committed Nov 21, 2023
1 parent a7d5b8a commit 2bb0470
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Controller/DAVController.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,26 @@ private function initExceptionListener()
*/
public function dav(Request $request, string $path)
{
// We need to acknowledge the OPTIONS call before sabre/dav for public
// calendars since we're circumventing the lib
if ('OPTIONS' === $request->getMethod()) {
return new Response();
$response = new Response();

// Adapted from CorePlugin's httpOptions()
// https://github.com/sabre-io/dav/blob/master/lib/DAV/CorePlugin.php#L210
$methods = $this->server->getAllowedMethods("");

$response->headers->set('Allow', strtoupper(implode(', ', $methods)));
$features = ['1', '3', 'extended-mkcol'];

foreach ($this->server->getPlugins() as $plugin) {
$features = array_merge($features, $plugin->getFeatures());
}

$response->headers->set('DAV', implode(', ', $features));
$response->headers->set('MS-Author-Via', 'DAV');

return $response;
}

// \Sabre\DAV\Server does not let us use a custom SAPI, and its behaviour
Expand Down

0 comments on commit 2bb0470

Please sign in to comment.