mirror of
https://github.com/openappsec/attachment.git
synced 2025-12-31 13:49:09 +03:00
try content-length nil
This commit is contained in:
@@ -250,10 +250,9 @@ function NanoHandler.body_filter(conf)
|
||||
ctx.cleanup_needed = true
|
||||
if ctx.response_buffer and #ctx.response_buffer > 0 then
|
||||
local buffered_data = table.concat(ctx.response_buffer)
|
||||
local original_content_length = tonumber(ngx.header["Content-Length"]) or #buffered_data
|
||||
local total_diff = ctx.content_length_diff or 0
|
||||
ngx.header["Content-Length"] = original_content_length + total_diff
|
||||
ngx.header["Content-Length"] = nil
|
||||
ngx.arg[1] = buffered_data
|
||||
ctx.response_buffer = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -264,7 +263,6 @@ function NanoHandler.body_filter(conf)
|
||||
|
||||
if chunk and #chunk > 0 then
|
||||
ctx.body_buffer_chunk = ctx.body_buffer_chunk or 0
|
||||
ctx.content_length_diff = ctx.content_length_diff or 0
|
||||
ctx.body_seen = true
|
||||
|
||||
table.insert(ctx.response_buffer, chunk)
|
||||
@@ -272,10 +270,8 @@ function NanoHandler.body_filter(conf)
|
||||
local verdict, response, modifications = nano.send_body(session_id, session_data, chunk, nano.HttpChunkType.HTTP_RESPONSE_BODY)
|
||||
|
||||
if modifications then
|
||||
local original_length = #chunk
|
||||
chunk = nano.handle_body_modifications(chunk, modifications, ctx.body_buffer_chunk)
|
||||
local modified_length = #chunk
|
||||
ctx.content_length_diff = ctx.content_length_diff + (modified_length - original_length)
|
||||
ctx.response_buffer[#ctx.response_buffer] = chunk
|
||||
end
|
||||
|
||||
@@ -300,9 +296,7 @@ function NanoHandler.body_filter(conf)
|
||||
return
|
||||
else
|
||||
local buffered_data = table.concat(ctx.response_buffer)
|
||||
local original_content_length = tonumber(ngx.header["Content-Length"]) or #buffered_data
|
||||
local total_diff = ctx.content_length_diff or 0
|
||||
ngx.header["Content-Length"] = original_content_length + total_diff
|
||||
ngx.header["Content-Length"] = nil
|
||||
ngx.arg[1] = buffered_data
|
||||
ctx.response_buffer = nil
|
||||
return
|
||||
@@ -340,9 +334,7 @@ function NanoHandler.body_filter(conf)
|
||||
|
||||
if ctx.response_buffer and #ctx.response_buffer > 0 then
|
||||
local buffered_data = table.concat(ctx.response_buffer)
|
||||
local original_content_length = tonumber(ngx.header["Content-Length"]) or #buffered_data
|
||||
local total_diff = ctx.content_length_diff or 0
|
||||
ngx.header["Content-Length"] = original_content_length + total_diff
|
||||
ngx.header["Content-Length"] = #buffered_data
|
||||
ngx.arg[1] = buffered_data
|
||||
else
|
||||
kong.log.debug("No buffered chunks to flush (empty response)")
|
||||
|
||||
Reference in New Issue
Block a user