Fix for issue #94 by Leonard Richardson
diff --git a/python2/httplib2/__init__.py b/python2/httplib2/__init__.py
index 3054051..21dc86a 100644
--- a/python2/httplib2/__init__.py
+++ b/python2/httplib2/__init__.py
@@ -1064,7 +1064,7 @@
                 for header in vary_headers:
                     key = '-varied-%s' % header
                     value = info[key]
-                    if headers.get(header, '') != value:
+                    if headers.get(header, None) != value:
                             cached_value = None
                             break
 
diff --git a/python2/httplib2test.py b/python2/httplib2test.py
index 2c132af..5a81a70 100755
--- a/python2/httplib2test.py
+++ b/python2/httplib2test.py
@@ -636,6 +636,19 @@
         self.assertEqual(response.status, 200)
         self.assertEqual(response.fromcache, False, msg="Should not be from cache")
 
+    def testVaryUnusedHeader(self):
+        # A header's value is not considered to vary if it's not used at all.
+        uri = urlparse.urljoin(base, "vary/unused-header.asis")
+        (response, content) = self.http.request(uri, "GET", headers={
+            'Accept': 'text/plain'})
+        self.assertEqual(response.status, 200)
+        self.assertTrue(response.has_key('vary'))
+
+        # we are from cache
+        (response, content) = self.http.request(uri, "GET", headers={
+            'Accept': 'text/plain',})
+        self.assertEqual(response.fromcache, True, msg="Should be from cache")
+
 
     def testHeadGZip(self):
         # Test that we don't try to decompress a HEAD response 
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index ccd4d46..5ca8c3a 100644
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -1052,7 +1052,7 @@
                 for header in vary_headers:
                     key = '-varied-%s' % header
                     value = info[key]
-                    if headers.get(header, '') != value:
+                    if headers.get(header, None) != value:
                             cached_value = None
                             break
 
diff --git a/python3/httplib2test.py b/python3/httplib2test.py
index 46a850d..264677c 100755
--- a/python3/httplib2test.py
+++ b/python3/httplib2test.py
@@ -634,6 +634,19 @@
         self.assertEqual(response.status, 200)

         self.assertEqual(response.fromcache, False, msg="Should not be from cache")

 

+    def testVaryUnusedHeader(self):

+        # A header's value is not considered to vary if it's not used at all.

+        uri = urllib.parse.urljoin(base, "vary/unused-header.asis")

+        (response, content) = self.http.request(uri, "GET", headers={

+            'Accept': 'text/plain'})

+        self.assertEqual(response.status, 200)

+        self.assertTrue('vary' in response)

+

+        # we are from cache

+        (response, content) = self.http.request(uri, "GET", headers={

+            'Accept': 'text/plain',})

+        self.assertEqual(response.fromcache, True, msg="Should be from cache")

+

     def testHeadGZip(self):

         # Test that we don't try to decompress a HEAD response 

         uri = urllib.parse.urljoin(base, "gzip/final-destination.txt")

diff --git a/test/vary/unused-header.asis b/test/vary/unused-header.asis
new file mode 100644
index 0000000..2002f48
--- /dev/null
+++ b/test/vary/unused-header.asis
@@ -0,0 +1,6 @@
+#!/usr/bin/tail --lines=+2
+Content-Type: text/plain
+Vary: X-No-Such-Header
+Status: 200 OK
+
+I've never heard of a header called X-No-Such-Header.