From b1d974cea261c0385890484efd1c8bf4f030962d Mon Sep 17 00:00:00 2001 From: wiaamm Date: Wed, 19 Nov 2025 11:37:53 +0200 Subject: [PATCH] fix response body --- .../kong/plugins/open-appsec-waf-kong-plugin/handler.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/attachments/kong/plugins/open-appsec-waf-kong-plugin/handler.lua b/attachments/kong/plugins/open-appsec-waf-kong-plugin/handler.lua index 0cacbd8..7ebe9d7 100755 --- a/attachments/kong/plugins/open-appsec-waf-kong-plugin/handler.lua +++ b/attachments/kong/plugins/open-appsec-waf-kong-plugin/handler.lua @@ -157,9 +157,13 @@ function NanoHandler.header_filter(conf) local status_code = kong.response.get_status() local content_length = tonumber(headers["content-length"]) or 0 - kong.log.debug("[header_filter] Session: ", session_id, " | Status: ", status_code, " | Content-Length: ", content_length) + -- For responses that will be streamed in chunks via body_filter, pass 0 content_length + -- to prevent nano service from trying to read the entire body at once + local nano_content_length = 0 - local verdict, response = nano.send_response_headers(session_id, session_data, header_data, status_code, content_length) + kong.log.debug("[header_filter] Session: ", session_id, " | Status: ", status_code, " | Content-Length: ", content_length, " | Nano Content-Length: ", nano_content_length) + + local verdict, response = nano.send_response_headers(session_id, session_data, header_data, status_code, nano_content_length) if verdict == nano.AttachmentVerdict.DROP then kong.log.warn("[header_filter] Response headers verdict DROP for session: ", session_id) kong.ctx.plugin.blocked = true