Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cachecontrol/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions tests/test_cache_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down