2017-07-13 04:09:18 +00:00
|
|
|
from django.core.exceptions import (
|
|
|
|
DisallowedHost, PermissionDenied, SuspiciousOperation,
|
|
|
|
)
|
|
|
|
from django.http import (
|
|
|
|
Http404, HttpResponse, HttpResponseRedirect, HttpResponseServerError,
|
|
|
|
)
|
|
|
|
from django.http.multipartparser import MultiPartParserError
|
2016-04-13 21:38:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
def innocent(request):
|
|
|
|
return HttpResponse('innocent')
|
2013-05-15 23:14:28 +00:00
|
|
|
|
|
|
|
|
2017-07-13 04:09:18 +00:00
|
|
|
def redirect(request):
|
|
|
|
return HttpResponseRedirect('/')
|
|
|
|
|
|
|
|
|
2013-05-15 23:14:28 +00:00
|
|
|
def suspicious(request):
|
|
|
|
raise SuspiciousOperation('dubious')
|
|
|
|
|
|
|
|
|
|
|
|
def suspicious_spec(request):
|
|
|
|
raise DisallowedHost('dubious')
|
2017-07-13 04:09:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UncaughtException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def uncaught_exception(request):
|
|
|
|
raise UncaughtException('Uncaught exception')
|
|
|
|
|
|
|
|
|
|
|
|
def internal_server_error(request):
|
|
|
|
status = request.GET.get('status', 500)
|
|
|
|
return HttpResponseServerError('Server Error', status=int(status))
|
|
|
|
|
|
|
|
|
|
|
|
def permission_denied(request):
|
|
|
|
raise PermissionDenied()
|
|
|
|
|
|
|
|
|
|
|
|
def multi_part_parser_error(request):
|
|
|
|
raise MultiPartParserError('parsing error')
|
|
|
|
|
|
|
|
|
|
|
|
def does_not_exist_raised(request):
|
|
|
|
raise Http404('Not Found')
|