Skip to content

Commit

Permalink
[#222] fix cache header test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonny Bakker committed Sep 29, 2022
1 parent 51e7969 commit be48c29
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vng_api_common/caching/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@


def has_cache_header(view: GenericAPIView) -> bool:
if view.request is None:
return False
request = getattr(view, "request", None)
method = getattr(view, "method", None) or request.method if request else None
action = getattr(view, "action", None)

method = view.request.method
if method not in ("GET", "HEAD"):
if method not in ("GET", "HEAD") and action not in (
"retrieve",
"headers",
):
return False

if hasattr(view, "detail") and not view.detail:
Expand Down

0 comments on commit be48c29

Please sign in to comment.