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
|
ctx.cleanup_needed = true
|
||||||
if ctx.response_buffer and #ctx.response_buffer > 0 then
|
if ctx.response_buffer and #ctx.response_buffer > 0 then
|
||||||
local buffered_data = table.concat(ctx.response_buffer)
|
local buffered_data = table.concat(ctx.response_buffer)
|
||||||
local original_content_length = tonumber(ngx.header["Content-Length"]) or #buffered_data
|
ngx.header["Content-Length"] = nil
|
||||||
local total_diff = ctx.content_length_diff or 0
|
|
||||||
ngx.header["Content-Length"] = original_content_length + total_diff
|
|
||||||
ngx.arg[1] = buffered_data
|
ngx.arg[1] = buffered_data
|
||||||
|
ctx.response_buffer = nil
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -264,7 +263,6 @@ function NanoHandler.body_filter(conf)
|
|||||||
|
|
||||||
if chunk and #chunk > 0 then
|
if chunk and #chunk > 0 then
|
||||||
ctx.body_buffer_chunk = ctx.body_buffer_chunk or 0
|
ctx.body_buffer_chunk = ctx.body_buffer_chunk or 0
|
||||||
ctx.content_length_diff = ctx.content_length_diff or 0
|
|
||||||
ctx.body_seen = true
|
ctx.body_seen = true
|
||||||
|
|
||||||
table.insert(ctx.response_buffer, chunk)
|
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)
|
local verdict, response, modifications = nano.send_body(session_id, session_data, chunk, nano.HttpChunkType.HTTP_RESPONSE_BODY)
|
||||||
|
|
||||||
if modifications then
|
if modifications then
|
||||||
local original_length = #chunk
|
|
||||||
chunk = nano.handle_body_modifications(chunk, modifications, ctx.body_buffer_chunk)
|
chunk = nano.handle_body_modifications(chunk, modifications, ctx.body_buffer_chunk)
|
||||||
local modified_length = #chunk
|
local modified_length = #chunk
|
||||||
ctx.content_length_diff = ctx.content_length_diff + (modified_length - original_length)
|
|
||||||
ctx.response_buffer[#ctx.response_buffer] = chunk
|
ctx.response_buffer[#ctx.response_buffer] = chunk
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -300,9 +296,7 @@ function NanoHandler.body_filter(conf)
|
|||||||
return
|
return
|
||||||
else
|
else
|
||||||
local buffered_data = table.concat(ctx.response_buffer)
|
local buffered_data = table.concat(ctx.response_buffer)
|
||||||
local original_content_length = tonumber(ngx.header["Content-Length"]) or #buffered_data
|
ngx.header["Content-Length"] = nil
|
||||||
local total_diff = ctx.content_length_diff or 0
|
|
||||||
ngx.header["Content-Length"] = original_content_length + total_diff
|
|
||||||
ngx.arg[1] = buffered_data
|
ngx.arg[1] = buffered_data
|
||||||
ctx.response_buffer = nil
|
ctx.response_buffer = nil
|
||||||
return
|
return
|
||||||
@@ -340,9 +334,7 @@ function NanoHandler.body_filter(conf)
|
|||||||
|
|
||||||
if ctx.response_buffer and #ctx.response_buffer > 0 then
|
if ctx.response_buffer and #ctx.response_buffer > 0 then
|
||||||
local buffered_data = table.concat(ctx.response_buffer)
|
local buffered_data = table.concat(ctx.response_buffer)
|
||||||
local original_content_length = tonumber(ngx.header["Content-Length"]) or #buffered_data
|
ngx.header["Content-Length"] = #buffered_data
|
||||||
local total_diff = ctx.content_length_diff or 0
|
|
||||||
ngx.header["Content-Length"] = original_content_length + total_diff
|
|
||||||
ngx.arg[1] = buffered_data
|
ngx.arg[1] = buffered_data
|
||||||
else
|
else
|
||||||
kong.log.debug("No buffered chunks to flush (empty response)")
|
kong.log.debug("No buffered chunks to flush (empty response)")
|
||||||
|
|||||||
Reference in New Issue
Block a user