Skip to content

Commit

Permalink
Clearer variable name - page_needs_vary_header
Browse files Browse the repository at this point in the history
page_needs_vary_cookie sounded like the variable controlled setting a cookie.
  • Loading branch information
simonw committed Jun 6, 2020
1 parent 65f6ab5 commit 01a428d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions asgi_csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def app_wrapped_with_csrf(scope, receive, send):
csrftoken = None
has_csrftoken_cookie = False
should_set_cookie = False
page_needs_vary_cookie = False
page_needs_vary_header = False
if cookie_name in cookies:
try:
csrftoken = cookies.get(cookie_name, "")
Expand All @@ -49,8 +49,8 @@ async def app_wrapped_with_csrf(scope, receive, send):

def get_csrftoken():
nonlocal should_set_cookie
nonlocal page_needs_vary_cookie
page_needs_vary_cookie = True
nonlocal page_needs_vary_header
page_needs_vary_header = True
if not has_csrftoken_cookie:
should_set_cookie = True
return csrftoken
Expand All @@ -61,7 +61,7 @@ async def wrapped_send(event):
if event["type"] == "http.response.start":
original_headers = event.get("headers") or []
new_headers = []
if page_needs_vary_cookie:
if page_needs_vary_header:
# Loop through original headers, modify or add "vary"
found_vary = False
for key, value in original_headers:
Expand Down

0 comments on commit 01a428d

Please sign in to comment.