2009-03-22 07:58:29 +00:00
|
|
|
from django.http import HttpResponse
|
2015-01-28 07:35:27 -05:00
|
|
|
from django.views.decorators.http import condition, etag, last_modified
|
2009-03-22 07:58:29 +00:00
|
|
|
|
2016-09-12 23:26:24 -04:00
|
|
|
from .tests import ETAG, FULL_RESPONSE, LAST_MODIFIED, WEAK_ETAG
|
2011-10-13 18:51:33 +00:00
|
|
|
|
2009-03-22 07:58:29 +00:00
|
|
|
|
2016-09-10 08:23:53 -04:00
|
|
|
@condition(lambda r: ETAG, lambda r: LAST_MODIFIED)
|
2009-03-22 07:58:29 +00:00
|
|
|
def index(request):
|
|
|
|
return HttpResponse(FULL_RESPONSE)
|
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2016-09-10 08:23:53 -04:00
|
|
|
@condition(last_modified_func=lambda r: LAST_MODIFIED)
|
2009-03-24 03:01:46 +00:00
|
|
|
def last_modified_view1(request):
|
2009-03-22 07:58:29 +00:00
|
|
|
return HttpResponse(FULL_RESPONSE)
|
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2016-09-10 08:23:53 -04:00
|
|
|
@last_modified(lambda r: LAST_MODIFIED)
|
2009-03-24 03:01:46 +00:00
|
|
|
def last_modified_view2(request):
|
2009-03-22 07:58:29 +00:00
|
|
|
return HttpResponse(FULL_RESPONSE)
|
2009-03-24 03:01:46 +00:00
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2016-09-10 08:23:53 -04:00
|
|
|
@condition(etag_func=lambda r: ETAG)
|
2009-03-24 03:01:46 +00:00
|
|
|
def etag_view1(request):
|
|
|
|
return HttpResponse(FULL_RESPONSE)
|
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2016-09-10 08:23:53 -04:00
|
|
|
@etag(lambda r: ETAG)
|
2009-03-24 03:01:46 +00:00
|
|
|
def etag_view2(request):
|
|
|
|
return HttpResponse(FULL_RESPONSE)
|
2016-09-01 09:32:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
@condition(etag_func=lambda r: ETAG.strip('"'))
|
|
|
|
def etag_view_unquoted(request):
|
|
|
|
"""
|
|
|
|
Use an etag_func() that returns an unquoted ETag.
|
|
|
|
"""
|
|
|
|
return HttpResponse(FULL_RESPONSE)
|
|
|
|
|
|
|
|
|
2016-09-12 23:26:24 -04:00
|
|
|
@condition(etag_func=lambda r: WEAK_ETAG)
|
|
|
|
def etag_view_weak(request):
|
|
|
|
"""
|
|
|
|
Use an etag_func() that returns a weak ETag.
|
|
|
|
"""
|
|
|
|
return HttpResponse(FULL_RESPONSE)
|
|
|
|
|
|
|
|
|
2016-09-01 09:32:20 -04:00
|
|
|
@condition(etag_func=lambda r: None)
|
|
|
|
def etag_view_none(request):
|
|
|
|
"""
|
|
|
|
Use an etag_func() that returns None, as opposed to setting etag_func=None.
|
|
|
|
"""
|
|
|
|
return HttpResponse(FULL_RESPONSE)
|