Made @vary_on_cookie decorator reuse @vary_on_headers.
This commit is contained in:
parent
f7cfa48283
commit
fb1c763506
@ -27,20 +27,8 @@ def vary_on_headers(*headers):
|
|||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def vary_on_cookie(func):
|
vary_on_cookie = vary_on_headers("Cookie")
|
||||||
"""
|
vary_on_cookie.__doc__ = (
|
||||||
A view decorator that adds "Cookie" to the Vary header of a response. This
|
'A view decorator that adds "Cookie" to the Vary header of a response. This '
|
||||||
indicates that a page's contents depends on cookies. Usage:
|
"indicates that a page's contents depends on cookies."
|
||||||
|
)
|
||||||
@vary_on_cookie
|
|
||||||
def index(request):
|
|
||||||
...
|
|
||||||
"""
|
|
||||||
|
|
||||||
@wraps(func)
|
|
||||||
def inner_func(*args, **kwargs):
|
|
||||||
response = func(*args, **kwargs)
|
|
||||||
patch_vary_headers(response, ("Cookie",))
|
|
||||||
return response
|
|
||||||
|
|
||||||
return inner_func
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user