From b8cd4fd2dcbbaf47e2a4167f169abeaa59d46173 Mon Sep 17 00:00:00 2001 From: cel Date: Wed, 15 Jan 2020 10:08:55 -0500 Subject: Format etags better Quote and capitalize properly --- lib/serve.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/serve.js b/lib/serve.js index cf9357e..b4efc58 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1480,7 +1480,7 @@ Serve.prototype.highlight = function (dirs) { Serve.prototype.blob = function (id, path) { var self = this var unbox = typeof this.query.unbox === 'string' && this.query.unbox.replace(/\s/g, '+') - var etag = id + (path || '') + (unbox || '') + var etag = '"' + id + (path || '') + (unbox || '') + '"' if (self.req.headers['if-none-match'] === etag) return self.respond(304) var key if (path) { @@ -1522,7 +1522,7 @@ Serve.prototype.blob = function (id, path) { if (self.query.name) self.res.setHeader('Content-Disposition', 'inline; filename='+encodeDispositionFilename(self.query.name)) self.res.setHeader('Cache-Control', 'public, max-age=315360000') - self.res.setHeader('etag', etag) + self.res.setHeader('ETag', etag) self.res.writeHead(200) } }) @@ -1534,7 +1534,7 @@ Serve.prototype.image = function (path) { var m = urlIdRegex.exec(path) if (m && m[2] === '&') id = m[1], path = m[3] var unbox = typeof this.query.unbox === 'string' && this.query.unbox.replace(/\s/g, '+') - var etag = 'image-' + id + (path || '') + (unbox || '') + var etag = '"image-' + id + (path || '') + (unbox || '') + '"' if (self.req.headers['if-none-match'] === etag) return self.respond(304) if (path) { try { path = decodeURIComponent(path) } catch(e) {} @@ -1603,7 +1603,7 @@ Serve.prototype.image = function (path) { if (self.query.name) self.res.setHeader('Content-Disposition', 'inline; filename='+encodeDispositionFilename(self.query.name)) self.res.setHeader('Cache-Control', 'public, max-age=315360000') - self.res.setHeader('etag', etag) + self.res.setHeader('ETag', etag) self.res.writeHead(200) }) }) @@ -2072,7 +2072,7 @@ Serve.prototype.gitRaw = function (rev) { type = type && mime.lookup(type) if (type) self.res.setHeader('Content-Type', type) self.res.setHeader('Cache-Control', 'public, max-age=315360000') - self.res.setHeader('etag', rev) + self.res.setHeader('ETag', rev) self.res.writeHead(200) }), self.respondSink() @@ -3098,7 +3098,7 @@ Serve.prototype.zip = function (url) { var id = decodeURIComponent(parts.shift()) var filename = parts.join('/') var blobs = self.app.sbot.blobs - var etag = id + filename + var etag = '"' + id + filename + '"' var index = filename === '' || /\/$/.test(filename) var indexFilename = index && (filename + 'index.html') if (filename === '/' || /\/\/$/.test(filename)) { @@ -3182,7 +3182,7 @@ Serve.prototype.zip = function (url) { if (type) self.res.setHeader('Content-Type', type) if (size) self.res.setHeader('Content-Length', size) self.res.setHeader('Cache-Control', 'public, max-age=315360000') - self.res.setHeader('etag', etag) + self.res.setHeader('ETag', etag) self.res.writeHead(200) } }) -- cgit v1.2.3