set Vary: Cookie header consistently for session
This commit is contained in:
parent
9532cba45d
commit
8705dd39c4
2 changed files with 29 additions and 4 deletions
|
|
@ -329,6 +329,10 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
samesite = self.get_cookie_samesite(app)
|
||||
httponly = self.get_cookie_httponly(app)
|
||||
|
||||
# Add a "Vary: Cookie" header if the session was accessed at all.
|
||||
if session.accessed:
|
||||
response.vary.add("Cookie")
|
||||
|
||||
# If the session is modified to be empty, remove the cookie.
|
||||
# If the session is empty, return without setting the cookie.
|
||||
if not session:
|
||||
|
|
@ -341,13 +345,10 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
samesite=samesite,
|
||||
httponly=httponly,
|
||||
)
|
||||
response.vary.add("Cookie")
|
||||
|
||||
return
|
||||
|
||||
# Add a "Vary: Cookie" header if the session was accessed at all.
|
||||
if session.accessed:
|
||||
response.vary.add("Cookie")
|
||||
|
||||
if not self.should_set_cookie(app, session):
|
||||
return
|
||||
|
||||
|
|
@ -363,3 +364,4 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
secure=secure,
|
||||
samesite=samesite,
|
||||
)
|
||||
response.vary.add("Cookie")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue