1. support gunzip within 'if in location' (conditional gunzip according to an if-statement evaluated in the rewrite phase)
2. gunzip on|off|always|types ( == gunzip even if the client supports it. == gunzip only mime-types specified with )
See updated README https://github.com/alonbg/ngx_http_gunzip_filter_module
Example:
location /test {
proxy_pass ....;
header_filter_by_lua_block {
check_some_condition_and set_ctx()
}
gunzip_types text/_javascript_;
gunzip types;
#optional and if linked in the right order
replace_filter_types text/_javascript_;
replace_filter .......;
body_filter_by_lua_block {
local chunk, eof = ngx.arg[1], ngx.arg[2]
local buffered = ngx.ctx.buffered
if not buffered then
buffered = {}
ngx.ctx.buffered = buffered
end
if chunk ~= "" then
buffered[#buffered + 1] = chunk
ngx.arg[1] = nil
end
if not eof then
return
end
ngx.ctx.buffered = nil
ngx.arg[1] = process_response(buffered)
}
gzip_types text/_javascript_;
gzip on;
}
/Alon