/** * Serve WebDAV HTTP request. * @param DAV_Registry $registry */ public function handleRequest() { // We want to catch every exception thrown in this code, and report about it // to the user appropriately. $shallow_lock = false; try { $shallow_lock = $this->check_if_headers(); $resource = DAV::$REGISTRY->resource(DAV::getPath()); if (!$resource || !$resource->isVisible() and in_array($_SERVER['REQUEST_METHOD'], array('ACL', 'COPY', 'DELETE', 'GET', 'HEAD', 'MOVE', 'OPTIONS', 'POST', 'PROPFIND', 'PROPPATCH', 'REPORT', 'UNLOCK'))) { throw new DAV_Status(DAV::HTTP_NOT_FOUND); } if ('/' !== substr(DAV::getPath(), -1) && ($resource && $resource instanceof DAV_Collection || 'MKCOL' === $_SERVER['REQUEST_METHOD'])) { $newPath = DAV::getPath() . '/'; DAV::setPath(DAV::encodeURIFullPath($newPath)); DAV::header(array('Content-Location' => DAV::path2uri($newPath))); } $this->handle($resource); } catch (Exception $e) { if (!$e instanceof DAV_Status) { $e = new DAV_Status(DAV::HTTP_INTERNAL_SERVER_ERROR, "{$e}"); } $e->output(); } if ($shallow_lock) { DAV::$REGISTRY->shallowUnlock(); } if (DAV_Multistatus::active()) { DAV_Multistatus::inst()->close(); } }