aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Server.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/Server.php')
-rw-r--r--apps/dav/lib/Server.php33
1 files changed, 23 insertions, 10 deletions
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php
index 759d39c0233..589e6c2bd6c 100644
--- a/apps/dav/lib/Server.php
+++ b/apps/dav/lib/Server.php
@@ -36,6 +36,9 @@ namespace OCA\DAV;
use OCA\DAV\Connector\Sabre\RequestIdHeaderPlugin;
use OCP\Diagnostics\IEventLogger;
+use OCP\Profiler\IProfiler;
+use OCA\DAV\Profiler\ProfilerPlugin;
+use OCP\AppFramework\Http\Response;
use Psr\Log\LoggerInterface;
use OCA\DAV\AppInfo\PluginManager;
use OCA\DAV\CalDAV\BirthdayService;
@@ -49,6 +52,7 @@ use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\Connector\Sabre\BearerAuth;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use OCA\DAV\Connector\Sabre\CachingTree;
+use OCA\DAV\Connector\Sabre\ChecksumUpdatePlugin;
use OCA\DAV\Connector\Sabre\CommentPropertiesPlugin;
use OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin;
use OCA\DAV\Connector\Sabre\DavAclPlugin;
@@ -78,17 +82,19 @@ use Sabre\DAV\UUIDUtil;
use SearchDAV\DAV\SearchPlugin;
class Server {
+ private IRequest $request;
+ private string $baseUri;
+ public Connector\Sabre\Server $server;
+ private IProfiler $profiler;
+
+ public function __construct(IRequest $request, string $baseUri) {
+ $this->profiler = \OC::$server->get(IProfiler::class);
+ if ($this->profiler->isEnabled()) {
+ /** @var IEventLogger $eventLogger */
+ $eventLogger = \OC::$server->get(IEventLogger::class);
+ $eventLogger->start('runtime', 'DAV Runtime');
+ }
- /** @var IRequest */
- private $request;
-
- /** @var string */
- private $baseUri;
-
- /** @var Connector\Sabre\Server */
- public $server;
-
- public function __construct(IRequest $request, $baseUri) {
$this->request = $request;
$this->baseUri = $baseUri;
$logger = \OC::$server->getLogger();
@@ -115,6 +121,7 @@ class Server {
$this->server->httpRequest->setUrl($this->request->getRequestUri());
$this->server->setBaseUri($this->baseUri);
+ $this->server->addPlugin(new ProfilerPlugin($this->request));
$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
$this->server->addPlugin(new AnonymousOptionsPlugin());
$authPlugin = new Plugin();
@@ -247,6 +254,7 @@ class Server {
!\OC::$server->getConfig()->getSystemValue('debug', false)
)
);
+ $this->server->addPlugin(new ChecksumUpdatePlugin());
$this->server->addPlugin(
new \Sabre\DAV\PropertyStorage\Plugin(
@@ -343,6 +351,11 @@ class Server {
$eventLogger->start('dav_server_exec', '');
$this->server->exec();
$eventLogger->end('dav_server_exec');
+ if ($this->profiler->isEnabled()) {
+ $eventLogger->end('runtime');
+ $profile = $this->profiler->collect(\OC::$server->get(IRequest::class), new Response());
+ $this->profiler->saveProfile($profile);
+ }
}
private function requestIsForSubtree(array $subTrees): bool {