MCPcopy
hub / github.com/django/django / trace_view

Function trace_view

tests/test_client/views.py:36–60  ·  view source on GitHub ↗

A simple view that expects a TRACE request and echoes its status line. TRACE requests should not have an entity; the view will return a 400 status response if it is present.

(request)

Source from the content-addressed store, hash-verified

34
35
36def trace_view(request):
37 """
38 A simple view that expects a TRACE request and echoes its status line.
39
40 TRACE requests should not have an entity; the view will return a 400 status
41 response if it is present.
42 """
43 if request.method.upper() != "TRACE":
44 return HttpResponseNotAllowed("TRACE")
45 elif request.body:
46 return HttpResponseBadRequest("TRACE requests MUST NOT include an entity")
47 else:
48 protocol = request.META["SERVER_PROTOCOL"]
49 t = Template(
50 "{{ method }} {{ uri }} {{ version }}",
51 name="TRACE Template",
52 )
53 c = Context(
54 {
55 "method": request.method,
56 "uri": request.path,
57 "version": protocol,
58 }
59 )
60 return HttpResponse(t.render(c))
61
62
63def put_view(request):

Callers 1

Calls 6

renderMethod · 0.95
TemplateClass · 0.90
ContextClass · 0.90
HttpResponseClass · 0.90

Tested by 1