When the status code of the response is 404, it may redirect to a path with an appended slash if should_redirect_with_slash() returns True.
(self, request, response)
| 98 | return new_path |
| 99 | |
| 100 | def process_response(self, request, response): |
| 101 | """ |
| 102 | When the status code of the response is 404, it may redirect to a path |
| 103 | with an appended slash if should_redirect_with_slash() returns True. |
| 104 | """ |
| 105 | # If the given URL is "Not Found", then check if we should redirect to |
| 106 | # a path with a slash appended. |
| 107 | if response.status_code == 404 and self.should_redirect_with_slash(request): |
| 108 | response = self.response_redirect_class( |
| 109 | self.get_full_path_with_slash(request) |
| 110 | ) |
| 111 | |
| 112 | # Add the Content-Length header to non-streaming responses if not |
| 113 | # already set. |
| 114 | if not response.streaming and not response.has_header("Content-Length"): |
| 115 | response.headers["Content-Length"] = str(len(response.content)) |
| 116 | |
| 117 | return response |
| 118 | |
| 119 | |
| 120 | class BrokenLinkEmailsMiddleware(MiddlewareMixin): |
nothing calls this directly
no test coverage detected