mirror of
https://github.com/openappsec/attachment.git
synced 2025-12-31 05:39:07 +03:00
move ngx.arg[1] to the beginning
This commit is contained in:
@@ -249,6 +249,8 @@ function NanoHandler.header_filter(conf)
|
||||
end
|
||||
|
||||
function NanoHandler.body_filter(conf)
|
||||
local chunk = ngx.arg[1]
|
||||
local eof = ngx.arg[2]
|
||||
local ctx = kong.ctx.plugin
|
||||
if ctx.blocked or ctx.bypass_inspection then
|
||||
return
|
||||
@@ -258,9 +260,6 @@ function NanoHandler.body_filter(conf)
|
||||
local session_data = ctx.session_data
|
||||
|
||||
if not session_id or not session_data or ctx.session_finalized then
|
||||
-- Clear the chunk to release it from memory immediately
|
||||
-- Without this, Kong holds chunks in memory causing OOM
|
||||
ngx.arg[1] = nil
|
||||
return
|
||||
end
|
||||
|
||||
@@ -273,7 +272,6 @@ function NanoHandler.body_filter(conf)
|
||||
local verdict, response, modifications = nano.end_inspection(session_id, session_data, nano.HttpChunkType.HTTP_RESPONSE_END)
|
||||
|
||||
if modifications then
|
||||
local chunk = ngx.arg[1]
|
||||
chunk = nano.handle_body_modifications(chunk, modifications, ctx.body_buffer_chunk or 0)
|
||||
ngx.arg[1] = chunk
|
||||
end
|
||||
@@ -300,9 +298,6 @@ function NanoHandler.body_filter(conf)
|
||||
return
|
||||
end
|
||||
|
||||
local chunk = ngx.arg[1]
|
||||
local eof = ngx.arg[2]
|
||||
|
||||
if chunk and #chunk > 0 then
|
||||
ctx.body_buffer_chunk = ctx.body_buffer_chunk or 0
|
||||
ctx.body_seen = true
|
||||
|
||||
Reference in New Issue
Block a user