From 9da53b6bf7db86e328e6d1149b6b462811b06832 Mon Sep 17 00:00:00 2001
From: Lloyd Hilaiel <lloyd@hilaiel.com>
Date: Mon, 26 Mar 2012 22:21:22 -0600
Subject: [PATCH] update cache header tests because etagify lazy calculates
 content hashes for etag headers, see comment in commit contents

---
 tests/cache-header-tests.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/cache-header-tests.js b/tests/cache-header-tests.js
index 690af835b..ab9882b78 100755
--- a/tests/cache-header-tests.js
+++ b/tests/cache-header-tests.js
@@ -48,7 +48,19 @@ function doRequest(path, headers, cb) {
 function hasProperCacheHeaders(path) {
   return {
     topic: function() {
-      doRequest(path, {}, this.callback);
+      var self = this;
+      // note we do *two* requests to the same resource.  The way
+      // etagify works is to generate content based hashes on the first
+      // request, and then use them every subsequent request.  This
+      // minimizes complexity and buffering that we do, at the cost of
+      // the first client after server restart possibly getting a couple
+      // extra kilobytes over the wire in a 200-that-shoulda-been-a-304.
+      // See issue #1331 and https://github.com/lloyd/connect-etagify
+      // for more context.
+      doRequest(path, {}, function(err, r) {
+        if (err) self.callback(err, r);
+        else doRequest(path, {}, self.callback);
+      });
     },
     "returns 200 with content": function(err, r) {
       assert.strictEqual(r.statusCode, 200);
-- 
GitLab