mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #5047: patch_cache_control now respects existing max-age settings. Thanks, permon.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6434 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
632a424db7
commit
2dd882885b
1
AUTHORS
1
AUTHORS
@ -234,6 +234,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Jay Parlar <parlar@gmail.com>
|
Jay Parlar <parlar@gmail.com>
|
||||||
pavithran s <pavithran.s@gmail.com>
|
pavithran s <pavithran.s@gmail.com>
|
||||||
Barry Pederson <bp@barryp.org>
|
Barry Pederson <bp@barryp.org>
|
||||||
|
permonik@mesias.brnonet.cz
|
||||||
petr.marhoun@gmail.com
|
petr.marhoun@gmail.com
|
||||||
pgross@thoughtworks.com
|
pgross@thoughtworks.com
|
||||||
phaedo <http://phaedo.cx/>
|
phaedo <http://phaedo.cx/>
|
||||||
|
@ -57,6 +57,13 @@ def patch_cache_control(response, **kwargs):
|
|||||||
cc = dict([dictitem(el) for el in cc])
|
cc = dict([dictitem(el) for el in cc])
|
||||||
else:
|
else:
|
||||||
cc = {}
|
cc = {}
|
||||||
|
|
||||||
|
# If there's already a max-age header but we're being asked to set a new
|
||||||
|
# max-age, use the minumum of the two ages. In practice this happens when
|
||||||
|
# a decorator and a piece of middleware both operate on a given view.
|
||||||
|
if 'max-age' in cc and 'max_age' in kwargs:
|
||||||
|
kwargs['max_age'] = min(cc['max-age'], kwargs['max_age'])
|
||||||
|
|
||||||
for (k,v) in kwargs.items():
|
for (k,v) in kwargs.items():
|
||||||
cc[k.replace('_', '-')] = v
|
cc[k.replace('_', '-')] = v
|
||||||
cc = ', '.join([dictvalue(el) for el in cc.items()])
|
cc = ', '.join([dictvalue(el) for el in cc.items()])
|
||||||
|
Loading…
Reference in New Issue
Block a user