diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2020-01-15 10:08:55 -0500 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2020-01-15 10:09:58 -0500 |
commit | b8cd4fd2dcbbaf47e2a4167f169abeaa59d46173 (patch) | |
tree | ec1547320ce3cb05aba69ace239b6981f1b97d24 /lib | |
parent | 8567deb76bd68a039d3160a9623998bd91ab46bd (diff) | |
download | patchfoo-b8cd4fd2dcbbaf47e2a4167f169abeaa59d46173.tar.gz patchfoo-b8cd4fd2dcbbaf47e2a4167f169abeaa59d46173.zip |
Format etags better
Quote and capitalize properly
Diffstat (limited to 'lib')
-rw-r--r-- | lib/serve.js | 14 |
1 files 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) } }) |