forked from orbit-oss/flask
parent
5797416544
commit
b8eba0a3fa
3 changed files with 13 additions and 27 deletions
|
|
@ -1004,17 +1004,3 @@ def is_ip(value):
|
|||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def patch_vary_header(response, value):
|
||||
"""Add a value to the ``Vary`` header if it is not already present."""
|
||||
|
||||
header = response.headers.get('Vary', '')
|
||||
headers = [h for h in (h.strip() for h in header.split(',')) if h]
|
||||
lower_value = value.lower()
|
||||
|
||||
if not any(h.lower() == lower_value for h in headers):
|
||||
headers.append(value)
|
||||
|
||||
updated_header = ', '.join(headers)
|
||||
response.headers['Vary'] = updated_header
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from itsdangerous import BadSignature, URLSafeTimedSerializer
|
|||
from werkzeug.datastructures import CallbackDict
|
||||
from werkzeug.http import http_date, parse_date
|
||||
|
||||
from flask.helpers import patch_vary_header
|
||||
from . import Markup, json
|
||||
from ._compat import iteritems, text_type
|
||||
from .helpers import is_ip, total_seconds
|
||||
|
|
@ -407,7 +406,7 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
|
||||
# Add a "Vary: Cookie" header if the session was accessed at all.
|
||||
if session.accessed:
|
||||
patch_vary_header(response, 'Cookie')
|
||||
response.vary.add('Cookie')
|
||||
|
||||
if not self.should_set_cookie(app, session):
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue