SilentEntity commented on PR #11087: URL: https://github.com/apache/apisix/pull/11087#issuecomment-2021957243
When client connection is slow, and page is loading in chunks[streaming], the last chuck is getting dropped/overwritten. If one see the code last chuck will contain `eof` [end of file], and according to the lib [`brotli-ffi`](https://github.com/GenessyX/brotli-ffi/tree/master) the last chuck should be appended with `compressor:finish()`. But in the code if the last chunk is present, it's getting overwritten : ``` local chunk, eof = ngx.arg[1], ngx.arg[2] if type(chunk) == "string" and chunk ~= "" then local encode_chunk = ctx.compressor:compress(chunk) ngx.arg[1] = encode_chunk .. ctx.compressor:flush() end if eof then ngx.arg[1] = ctx.compressor:finish() <--- Problem ``` The fix should be to append the compressed `ngx.arg[1]` in the `eof`. ``` if eof then -- overwriting the arg[1], results into partial response ngx.arg[1] = ngx.arg[1] .. ctx.compressor:finish() <--- fix ``` Even if the `ngx.arg[1]` is not present in `eof`, it won't impact the last chuck. Test-case of this case is not producible, it will require network throttling with large upstream payload for real scenario. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
