From 06565fb4b802c38a60d4c6e0f4b65c26da18d69f Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Sun, 2 Jan 2022 14:15:56 -0800 Subject: [PATCH] root html is no longer invariant, serve it normally --- src/manager.js | 19 ++----------------- src/service.js | 2 ++ test/src/manager.js | 12 ------------ 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/manager.js b/src/manager.js index 65444a0..b5eff7a 100644 --- a/src/manager.js +++ b/src/manager.js @@ -25,13 +25,6 @@ class Manager { this.db = db; this.options = options; this.communication = new Communication(logger, db, options); - - // Precalculate the invariant root GET metadata. - this.getRootContent = Template.rootHTML(undefined, options); - const now = new Date(); - this.startTimeString = now.toGMTString(); - this.startTimeMs = now.getTime(); - this.getRootETag = common.generateETag(undefined, undefined, this.getRootContent); } @@ -61,16 +54,8 @@ class Manager { const _scope = _fileScope('getRoot'); this.logger.debug(_scope, 'called', { ctx }); - res.setHeader(Enum.Header.LastModified, this.startTimeString); - res.setHeader(Enum.Header.ETag, this.getRootETag); - - if (common.isClientCached(req, this.startTimeMs, this.getRootETag)) { - this.logger.debug(_scope, 'client cached response', { ctx }); - res.statusCode = 304; - res.end(); - return; - } - res.end(this.getRootContent); + const content = Template.rootHTML(ctx, this.options); + res.end(content); this.logger.info(_scope, 'finished', { ctx }); } diff --git a/src/service.js b/src/service.js index 6dcde1e..d493f8a 100644 --- a/src/service.js +++ b/src/service.js @@ -101,6 +101,8 @@ class Service extends Dingus { this.setResponseType(responseTypes, req, res, ctx); + await this.authenticator.sessionOptional(req, res, ctx, this.loginPath); + await this.manager.getRoot(req, res, ctx); } diff --git a/test/src/manager.js b/test/src/manager.js index 7db6b84..67283d7 100644 --- a/test/src/manager.js +++ b/test/src/manager.js @@ -59,18 +59,6 @@ describe('Manager', function () { await manager.getRoot(req, res, ctx); assert(res.end.called); }); - it('repeat response', async function () { - manager.startTime = (new Date()).toGMTString(); - common.isClientCached.returns(true); - await manager.getRoot(req, res, ctx); - assert(res.end.called); - }); - it('cached response', async function () { - common.isClientCached.returns(true); - await manager.getRoot(req, res, ctx); - assert(res.end.called); - assert.strictEqual(res.statusCode, 304); - }); }); // getRoot describe('getHealthcheck', function () { -- 2.45.2