public function getFolder(Path $path, Request $request, TokenInfo $tokenInfo) { if ($path->getUserId() !== $tokenInfo->getUserId()) { throw new ForbiddenException('path does not match authorized subject'); } if (!$this->hasReadScope($tokenInfo->getScope(), $path->getModuleName())) { throw new ForbiddenException('path does not match authorized scope'); } $folderVersion = $this->remoteStorage->getVersion($path); if (null === $folderVersion) { // folder does not exist, so we just invent this // ETag that will be the same for all empty folders $folderVersion = 'e:404'; } $requestedVersion = $this->stripQuotes($request->getHeader('If-None-Match')); if (null !== $requestedVersion) { if (in_array($folderVersion, $requestedVersion)) { //return new RemoteStorageResponse($request, 304, $folderVersion); $response = new Response(304, 'application/ld+json'); $response->setHeader('ETag', '"' . $folderVersion . '"'); return $response; } } $rsr = new Response(200, 'application/ld+json'); $rsr->setHeader('ETag', '"' . $folderVersion . '"'); if ('GET' === $request->getMethod()) { $rsr->setBody($this->remoteStorage->getFolder($path, $this->stripQuotes($request->getHeader('If-None-Match')))); } return $rsr; }