summaryrefslogtreecommitdiff
path: root/python3
diff options
context:
space:
mode:
authorJoe Gregorio <joe@bitworking.org>2009-07-16 20:11:28 -0400
committerJoe Gregorio <joe@bitworking.org>2009-07-16 20:11:28 -0400
commite314e8b6ed2dc56c1b8e66793756c994cd2e39c5 (patch)
treed40277738e18a8e65ea8cdc93ea90d066eb603d8 /python3
parente202d210b618cba29d2c300b17a2ffb8e003fd14 (diff)
downloadhttplib2-e314e8b6ed2dc56c1b8e66793756c994cd2e39c5.tar.gz
Fixed issue #58 - malformed cache-control headers would cause an exception
Diffstat (limited to 'python3')
-rwxr-xr-xpython3/httplib2/__init__.py4
-rwxr-xr-xpython3/httplib2test.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index 389c3fe..28a3ff9 100755
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -187,8 +187,8 @@ def _parse_cache_control(headers):
retval = {}
if 'cache-control' in headers:
parts = headers['cache-control'].split(',')
- parts_with_args = [tuple([x.strip() for x in part.split("=")]) for part in parts if -1 != part.find("=")]
- parts_wo_args = [(name.strip(), 1) for name in parts if -1 == name.find("=")]
+ parts_with_args = [tuple([x.strip().lower() for x in part.split("=", 1)]) for part in parts if -1 != part.find("=")]
+ parts_wo_args = [(name.strip().lower(), 1) for name in parts if -1 == name.find("=")]
retval = dict(parts_with_args + parts_wo_args)
return retval
diff --git a/python3/httplib2test.py b/python3/httplib2test.py
index 6db6756..bc9816f 100755
--- a/python3/httplib2test.py
+++ b/python3/httplib2test.py
@@ -978,6 +978,15 @@ class HttpPrivateTest(unittest.TestCase):
cc = httplib2._parse_cache_control({'cache-control': ' , '})
self.assertEqual(cc[''], 1)
+ try:
+ cc = httplib2._parse_cache_control({'cache-control': 'Max-age=3600;post-check=1800,pre-check=3600'})
+ self.assertTrue("max-age" in cc)
+ except:
+ self.fail("Should not throw exception")
+
+
+
+
def testNormalizeHeaders(self):
# Test that we normalize headers to lowercase
h = httplib2._normalize_headers({'Cache-Control': 'no-cache', 'Other': 'Stuff'})