| 1 |
from django.http import HttpResponse |
| 2 |
from django.views.decorators.http import condition, etag, last_modified |
| 3 |
|
| 4 |
from .tests import ETAG, FULL_RESPONSE, LAST_MODIFIED, WEAK_ETAG |
| 5 |
|
| 6 |
|
| 7 |
@condition(lambda r: ETAG, lambda r: LAST_MODIFIED) |
| 8 |
def index(request): |
| 9 |
return HttpResponse(FULL_RESPONSE) |
| 10 |
|
| 11 |
|
| 12 |
@condition(last_modified_func=lambda r: LAST_MODIFIED) |
| 13 |
def last_modified_view1(request): |
| 14 |
return HttpResponse(FULL_RESPONSE) |
| 15 |
|
| 16 |
|
| 17 |
@last_modified(lambda r: LAST_MODIFIED) |
| 18 |
def last_modified_view2(request): |
| 19 |
return HttpResponse(FULL_RESPONSE) |
| 20 |
|
| 21 |
|
| 22 |
@condition(etag_func=lambda r: ETAG) |
| 23 |
def etag_view1(request): |
| 24 |
return HttpResponse(FULL_RESPONSE) |
| 25 |
|
| 26 |
|
| 27 |
@etag(lambda r: ETAG) |
| 28 |
def etag_view2(request): |
| 29 |
return HttpResponse(FULL_RESPONSE) |
| 30 |
|
| 31 |
|
| 32 |
@condition(etag_func=lambda r: ETAG.strip('"')) |
| 33 |
def etag_view_unquoted(request): |
| 34 |
""" |
| 35 |
Use an etag_func() that returns an unquoted ETag. |
| 36 |
""" |
| 37 |
return HttpResponse(FULL_RESPONSE) |
| 38 |
|
| 39 |
|
| 40 |
@condition(etag_func=lambda r: WEAK_ETAG) |
| 41 |
def etag_view_weak(request): |
| 42 |
""" |
| 43 |
Use an etag_func() that returns a weak ETag. |
| 44 |
""" |
| 45 |
return HttpResponse(FULL_RESPONSE) |
| 46 |
|
| 47 |
|
| 48 |
@condition(etag_func=lambda r: None) |
| 49 |
def etag_view_none(request): |
| 50 |
""" |
| 51 |
Use an etag_func() that returns None, as opposed to setting etag_func=None. |
| 52 |
""" |
| 53 |
return HttpResponse(FULL_RESPONSE) |