Can be overridden in order to modify the response object before it's sent to the WSGI server. By default this will call all the :meth:`after_request` decorated functions. .. versionchanged:: 0.5 As of Flask 0.5 the functions registered for after request
(self, response: Response)
| 1296 | return None |
| 1297 | |
| 1298 | def process_response(self, response: Response) -> Response: |
| 1299 | """Can be overridden in order to modify the response object |
| 1300 | before it's sent to the WSGI server. By default this will |
| 1301 | call all the :meth:`after_request` decorated functions. |
| 1302 | |
| 1303 | .. versionchanged:: 0.5 |
| 1304 | As of Flask 0.5 the functions registered for after request |
| 1305 | execution are called in reverse order of registration. |
| 1306 | |
| 1307 | :param response: a :attr:`response_class` object. |
| 1308 | :return: a new response object or the same, has to be an |
| 1309 | instance of :attr:`response_class`. |
| 1310 | """ |
| 1311 | ctx = request_ctx._get_current_object() # type: ignore[attr-defined] |
| 1312 | |
| 1313 | for func in ctx._after_request_functions: |
| 1314 | response = self.ensure_sync(func)(response) |
| 1315 | |
| 1316 | for name in chain(request.blueprints, (None,)): |
| 1317 | if name in self.after_request_funcs: |
| 1318 | for func in reversed(self.after_request_funcs[name]): |
| 1319 | response = self.ensure_sync(func)(response) |
| 1320 | |
| 1321 | if not self.session_interface.is_null_session(ctx._session): |
| 1322 | self.session_interface.save_session(self, ctx._session, response) |
| 1323 | |
| 1324 | return response |
| 1325 | |
| 1326 | def do_teardown_request( |
| 1327 | self, |
no test coverage detected