public function testPath2uri() { $this->assertSame('https://webdav.org/absolute/path', DAV::path2uri('/absolute/path'), 'DAV::path2uri() should return correct uri with absolute path'); $this->assertSame('https://webdav.org/', DAV::path2uri('/'), 'DAV::path2uri() should return correct uri with root path'); $_SERVER['REQUEST_URI'] = '/requested/path'; $this->assertSame('https://webdav.org/requested/path/relative/path', DAV::path2uri('relative/path'), 'DAV::path2uri() should return correct uri with relative path'); }
/** * 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(); } }