Skip to content

Commit

Permalink
Support must-understand response directive
Browse files Browse the repository at this point in the history
  • Loading branch information
RazerM committed Apr 22, 2024
1 parent 8bff7d0 commit 9e043b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/werkzeug/datastructures/cache_control.py
Expand Up @@ -179,6 +179,8 @@ class ResponseCacheControl(_CacheControl):
`no_transform` is now a boolean instead of returning `None` whether
the directive is present or not.
`must_understand` added.
"""

public = cache_control_property("public", None, bool)
Expand All @@ -187,6 +189,7 @@ class ResponseCacheControl(_CacheControl):
proxy_revalidate = cache_control_property("proxy-revalidate", None, bool)
s_maxage = cache_control_property("s-maxage", None, int)
immutable = cache_control_property("immutable", None, bool)
must_understand = cache_control_property("must-understand", None, bool)


# circular dependencies
Expand Down
6 changes: 6 additions & 0 deletions src/werkzeug/datastructures/cache_control.pyi
Expand Up @@ -110,3 +110,9 @@ class ResponseCacheControl(_CacheControl):
def immutable(self, value: bool | None) -> None: ...
@immutable.deleter
def immutable(self) -> None: ...
@property
def must_understand(self) -> bool: ...
@must_understand.setter
def must_understand(self, value: bool | None) -> None: ...
@must_understand.deleter
def must_understand(self) -> None: ...
6 changes: 6 additions & 0 deletions tests/test_datastructures.py
Expand Up @@ -967,6 +967,12 @@ def test_min_fresh(self):
cc = ds.RequestCacheControl()
assert cc.min_fresh is None

def test_must_understand(self):
cc = ds.ResponseCacheControl([("must-understand", None)])
assert cc.must_understand is True
cc = ds.ResponseCacheControl()
assert cc.must_understand is False


class TestContentSecurityPolicy:
def test_construct(self):
Expand Down

0 comments on commit 9e043b4

Please sign in to comment.