If the request method is HEAD and either the IP is internal or the user is a logged-in staff member, return a response with an x-view header indicating the view function. This is used to lookup the view function for an arbitrary page.
(self, request, view_func, view_args, view_kwargs)
| 12 | """ |
| 13 | |
| 14 | def process_view(self, request, view_func, view_args, view_kwargs): |
| 15 | """ |
| 16 | If the request method is HEAD and either the IP is internal or the |
| 17 | user is a logged-in staff member, return a response with an x-view |
| 18 | header indicating the view function. This is used to lookup the view |
| 19 | function for an arbitrary page. |
| 20 | """ |
| 21 | if not hasattr(request, "user"): |
| 22 | raise ImproperlyConfigured( |
| 23 | "The XView middleware requires authentication middleware to " |
| 24 | "be installed. Edit your MIDDLEWARE setting to insert " |
| 25 | "'django.contrib.auth.middleware.AuthenticationMiddleware'." |
| 26 | ) |
| 27 | if request.method == "HEAD" and ( |
| 28 | request.META.get("REMOTE_ADDR") in settings.INTERNAL_IPS |
| 29 | or (request.user.is_active and request.user.is_staff) |
| 30 | ): |
| 31 | response = HttpResponse() |
| 32 | response.headers["X-View"] = get_view_name(view_func) |
| 33 | return response |
nothing calls this directly
no test coverage detected