From 6a295ac196bcaa0e8c8a649fd668e8bab2d9ea25 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Fri, 6 Dec 2013 21:46:11 +0400 Subject: [PATCH] don't send etags with errors --- lib/middleware.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/middleware.js b/lib/middleware.js index d36b601ca..5955685db 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -110,7 +110,10 @@ module.exports.log_and_etagify = function(req, res, next) { body = JSON.stringify(body, undefined, '\t') } - res.header('ETag', '"' + md5sum(body) + '"') + // don't send etags with errors + if (!res.statusCode || (res.statusCode >= 200 && res.statusCode < 300)) { + res.header('ETag', '"' + md5sum(body) + '"') + } } else { // send(null), send(204), etc. }