diff options
| author | Joe Gregorio <joe@bitworking.org> | 2009-07-16 20:11:28 -0400 |
|---|---|---|
| committer | Joe Gregorio <joe@bitworking.org> | 2009-07-16 20:11:28 -0400 |
| commit | e314e8b6ed2dc56c1b8e66793756c994cd2e39c5 (patch) | |
| tree | d40277738e18a8e65ea8cdc93ea90d066eb603d8 /python3 | |
| parent | e202d210b618cba29d2c300b17a2ffb8e003fd14 (diff) | |
| download | httplib2-e314e8b6ed2dc56c1b8e66793756c994cd2e39c5.tar.gz | |
Fixed issue #58 - malformed cache-control headers would cause an exception
Diffstat (limited to 'python3')
| -rwxr-xr-x | python3/httplib2/__init__.py | 4 | ||||
| -rwxr-xr-x | python3/httplib2test.py | 9 |
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'})
|
