From 2bb04701995f46bb02aec70e490d3d68ef4aa882 Mon Sep 17 00:00:00 2001 From: tchapi Date: Tue, 21 Nov 2023 10:02:17 +0100 Subject: [PATCH] fix: options call --- src/Controller/DAVController.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Controller/DAVController.php b/src/Controller/DAVController.php index 8f7e797..ddcf840 100644 --- a/src/Controller/DAVController.php +++ b/src/Controller/DAVController.php @@ -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