diff --git a/cachecontrol/controller.py b/cachecontrol/controller.py index 03b2218..9b31a26 100644 --- a/cachecontrol/controller.py +++ b/cachecontrol/controller.py @@ -112,7 +112,7 @@ def parse_cache_control(self, headers: Mapping[str, str]) -> dict[str, int | Non continue parts = cc_directive.split("=", 1) - directive = parts[0].strip() + directive = parts[0].strip().lower() try: typ, required = known_directives[directive] diff --git a/tests/test_cache_control.py b/tests/test_cache_control.py index 9d3d4d8..d95918f 100644 --- a/tests/test_cache_control.py +++ b/tests/test_cache_control.py @@ -113,6 +113,14 @@ def test_cache_response_no_store(self): cc.cache_response(self.req(), resp) assert not cc.cache.get(cache_url) + def test_cache_control_directives_case_insensitive(self, cc): + now = time.strftime(TIME_FMT, time.gmtime()) + resp = self.resp({"cache-control": "No-Store, max-age=3600", "date": now}) + + cc.cache_response(self.req(), resp) + + assert not cc.cache.set.called + def test_cache_response_no_store_with_etag(self, cc): resp = self.resp({"cache-control": "no-store", "ETag": "jfd9094r808"}) cc.cache_response(self.req(), resp)