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