Added in https://sourceforge.net/tracker/?func=detail&atid=818434&aid=1462092&group_id=161082, but modified and added unit tests.
diff --git a/httplib2/__init__.py b/httplib2/__init__.py
index 36cf402..0c0c00b 100644
--- a/httplib2/__init__.py
+++ b/httplib2/__init__.py
@@ -86,6 +86,11 @@
 # Which headers are hop-by-hop headers by default
 HOP_BY_HOP = ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade']
 
+def _get_end2end_headers(response):
+    hopbyhop = HOP_BY_HOP
+    hopbyhop.extend([x.strip() for x in response.get('connection', '').split(',')])
+    return [header for header in response.keys() if header not in hopbyhop]
+
 URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?")
 
 def parse_uri(uri):
@@ -390,11 +395,7 @@
 
     def request(self, method, request_uri, headers, content):
         """Modify the request headers"""
-        if 'connection' in headers:
-            hopbyhop = HOP_BY_HOP + [k.strip().lower() for k in headers['connection'].split(',') if k.strip().lower() != 'close']
-        else:
-            hopbyhop = HOP_BY_HOP
-        keys = [k for k in headers.keys() if k.lower() not in hopbyhop]
+        keys = _get_end2end_headers(headers)
         keylist = "".join(["%s " % k for k in keys])
         headers_val = "".join([headers[k] for k in keys])
         created = time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime())
@@ -663,10 +664,7 @@
                 # and overwrite their values in info.
                 # unless they are hop-by-hop, or are listed in the connection header.
 
-                hopbyhop = HOP_BY_HOP
-                hopbyhop.append([x.strip() for x in response.get('connection', '').split(',')])
-                end2end = [header for header in response.keys() if header not in hopbyhop]
-                for key in end2end:
+                for key in _get_end2end_headers(response):
                     info[key] = response[key]
                 merged_response = Response(info)
                 if hasattr(response, "_stale_digest"):
diff --git a/httplib2test.py b/httplib2test.py
index 88f1bdf..edfd108 100755
--- a/httplib2test.py
+++ b/httplib2test.py
@@ -544,6 +544,7 @@
         d = self.reflector(content)
         self.assertTrue(d.has_key('HTTP_USER_AGENT')) 
 
+# ------------------------------------------------------------------------
 
 class HttpPrivateTest(unittest.TestCase):
 
@@ -819,6 +820,30 @@
         expected = "quR/EWLAV4xLf9Zqyw4pDmfV9OY="
         self.assertEqual(expected, digest)
 
+    def testEnd2End(self):
+        # one end to end header
+        response = {'content-type': 'application/atom+xml', 'te': 'deflate'}
+        end2end = httplib2._get_end2end_headers(response)
+        self.assertTrue('content-type' in end2end)
+        self.assertTrue('te' not in end2end)
+        self.assertTrue('connection' not in end2end)
+
+        # one end to end header that gets eliminated
+        response = {'connection': 'content-type', 'content-type': 'application/atom+xml', 'te': 'deflate'}
+        end2end = httplib2._get_end2end_headers(response)
+        self.assertTrue('content-type' not in end2end)
+        self.assertTrue('te' not in end2end)
+        self.assertTrue('connection' not in end2end)
+
+        # Degenerate case of no headers
+        response = {}
+        end2end = httplib2._get_end2end_headers(response)
+        self.assertEquals(0, len(end2end))
+
+        # Degenerate case of connection referrring to a header not passed in 
+        response = {'connection': 'content-type'}
+        end2end = httplib2._get_end2end_headers(response)
+        self.assertEquals(0, len(end2end))
 
 unittest.main()