From fb1c7635065321d415ad8182caf986a824bf9650 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Mon, 10 Jul 2023 11:21:59 +0200 Subject: [PATCH] Made @vary_on_cookie decorator reuse @vary_on_headers. --- django/views/decorators/vary.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/django/views/decorators/vary.py b/django/views/decorators/vary.py index 6098a0fbc0..b1459295d2 100644 --- a/django/views/decorators/vary.py +++ b/django/views/decorators/vary.py @@ -27,20 +27,8 @@ def vary_on_headers(*headers): return decorator -def vary_on_cookie(func): - """ - A view decorator that adds "Cookie" to the Vary header of a response. This - indicates that a page's contents depends on cookies. Usage: - - @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 +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 ' + "indicates that a page's contents depends on cookies." +)