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