public function handle($path, Uri $baseUri, HttpRequest $request, StorageInterface $storage) { if (!$request->isGet() && !$request->isHead()) { return; } try { $resource = $storage->findResource($path); } catch (\OutOfBoundsException $e) { return new HttpResponse(WebDav::CODE_NOT_FOUND); } if ($resource->isCollection()) { return new HttpResponse(WebDav::CODE_NO_CONTENT); } $cacheControl = new CacheControlHeader(); $cacheControl->setPrivate(true)->setMustRevalidate(true)->setMaxAge(7200); if ($request->isGet() && ($response = $request->evaluatePreconditions($resource->getEtag()))) { return $response->setHeader($cacheControl); } $response = new HttpResponse(); $response->setHeader($cacheControl); $response->setHeader('Content-Type', $resource->getMediaType()); $response->setHeader('ETag', $resource->getEtag()); if ($request->isGet()) { $response->setEntity($resource->getInputStream()); } return $response; }