feat: audit log records the response status at every level (#34663)

At the METADATA and REQUEST audit levels the entry for each request had an empty response status, so a denied request looked the same as a successful one. The status code is now recorded at every audit level. It carries no request or response content, so the least detailed level can hold it too.

Part of #33249
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-24 19:15:03 +04:00
1 parent af44e5f92c
commit 89ecb59a2a
1 file changed
+2 -2
+2 -2
View File
@@ -230,8 +230,8 @@ class AuditLoggingMiddleware:
async with self._audit_context(request) as context:
async def send_wrapper(message: ASGISendEvent) -> None:
if self.audit_level == AuditLevel.REQUEST_RESPONSE and (
capture_body or message['type'] == 'http.response.start'
if message['type'] == 'http.response.start' or (
self.audit_level == AuditLevel.REQUEST_RESPONSE and capture_body
):
await self._capture_response(message, context)