diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-03-05 16:22:18 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-03-06 09:51:28 +0100 |
commit | 11b6cc3f68f55e1c5e725b737b39c0a7f79e0ec1 (patch) | |
tree | 4dbc0874cf0dcad37dde7e5cba581adc614af515 /core/Controller/NavigationController.php | |
parent | 723b8764d111fd414cf2e37ae06e0b9a29c9dff7 (diff) | |
download | nextcloud-server-11b6cc3f68f55e1c5e725b737b39c0a7f79e0ec1.tar.gz nextcloud-server-11b6cc3f68f55e1c5e725b737b39c0a7f79e0ec1.zip |
Replace logout href to avoid new etag on every request
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core/Controller/NavigationController.php')
-rw-r--r-- | core/Controller/NavigationController.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php index b178cb97cd5..2397fb3c7b4 100644 --- a/core/Controller/NavigationController.php +++ b/core/Controller/NavigationController.php @@ -56,12 +56,12 @@ class NavigationController extends OCSController { $navigation = $this->rewriteToAbsoluteUrls($navigation); } - $etag = md5(json_encode($navigation)); + $etag = $this->generateETag($navigation); if ($this->request->getHeader('If-None-Match') === $etag) { return new DataResponse([], Http::STATUS_NOT_MODIFIED); } $response = new DataResponse($navigation); - $response->setEtag($etag); + $response->setETag($etag); return $response; } @@ -77,16 +77,31 @@ class NavigationController extends OCSController { if ($absolute) { $navigation = $this->rewriteToAbsoluteUrls($navigation); } - $etag = md5(json_encode($navigation)); + $etag = $this->generateETag($navigation); if ($this->request->getHeader('If-None-Match') === $etag) { return new DataResponse([], Http::STATUS_NOT_MODIFIED); } $response = new DataResponse($navigation); - $response->setEtag($etag); + $response->setETag($etag); return $response; } /** + * Generate an ETag for a list of navigation entries + * + * @param array $navigation + * @return string + */ + private function generateETag(array $navigation): string { + foreach ($navigation as &$nav) { + if ($nav['id'] === 'logout') { + $nav['href'] = 'logout'; + } + } + return md5(json_encode($navigation)); + } + + /** * Rewrite href attribute of navigation entries to an absolute URL * * @param array $navigation |