2013-03-06 10:12:24 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2013-05-15 23:14:28 +00:00
|
|
|
from django.core.exceptions import SuspiciousOperation
|
2013-05-19 15:55:12 +00:00
|
|
|
from django.db import connection, transaction
|
2013-03-06 10:12:24 +00:00
|
|
|
from django.http import HttpResponse, StreamingHttpResponse
|
2014-11-21 20:47:46 +00:00
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
2013-03-06 10:12:24 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2013-03-06 10:12:24 +00:00
|
|
|
def regular(request):
|
|
|
|
return HttpResponse(b"regular content")
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2013-03-06 10:12:24 +00:00
|
|
|
def streaming(request):
|
|
|
|
return StreamingHttpResponse([b"streaming", b" ", b"content"])
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2013-03-06 10:12:24 +00:00
|
|
|
def in_transaction(request):
|
|
|
|
return HttpResponse(str(connection.in_atomic_block))
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2013-05-19 15:55:12 +00:00
|
|
|
@transaction.non_atomic_requests
|
2013-03-06 10:12:24 +00:00
|
|
|
def not_in_transaction(request):
|
|
|
|
return HttpResponse(str(connection.in_atomic_block))
|
2013-05-15 23:14:28 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2013-05-15 23:14:28 +00:00
|
|
|
def suspicious(request):
|
|
|
|
raise SuspiciousOperation('dubious')
|
2014-11-21 20:47:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
|
|
def malformed_post(request):
|
|
|
|
request.POST
|
|
|
|
return HttpResponse()
|