MCPcopy
hub / github.com/django/django / process_response

Method process_response

django/middleware/common.py:100–117  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
120class BrokenLinkEmailsMiddleware(MiddlewareMixin):

Callers

nothing calls this directly

Calls 3

has_headerMethod · 0.80

Tested by

no test coverage detected