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);
}
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 });
}
this.setResponseType(responseTypes, req, res, ctx);
+ await this.authenticator.sessionOptional(req, res, ctx, this.loginPath);
+
await this.manager.getRoot(req, res, ctx);
}
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 () {