summaryrefslogtreecommitdiff
path: root/tests/conditional_processing/views.py
blob: 47288dbc563245e6dc73e227ea708e6fd9f8223e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from django.http import HttpResponse
from django.views.decorators.http import condition, etag, last_modified

from .tests import ETAG, FULL_RESPONSE, LAST_MODIFIED


@condition(lambda r: ETAG, lambda r: LAST_MODIFIED)
def index(request):
    return HttpResponse(FULL_RESPONSE)


@condition(last_modified_func=lambda r: LAST_MODIFIED)
def last_modified_view1(request):
    return HttpResponse(FULL_RESPONSE)


@last_modified(lambda r: LAST_MODIFIED)
def last_modified_view2(request):
    return HttpResponse(FULL_RESPONSE)


@condition(etag_func=lambda r: ETAG)
def etag_view1(request):
    return HttpResponse(FULL_RESPONSE)


@etag(lambda r: ETAG)
def etag_view2(request):
    return HttpResponse(FULL_RESPONSE)


@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)


@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)