adding Content-Length header in header_filter_by_lua ?

23 views
Skip to first unread message

Pahud Hsieh

unread,
Sep 26, 2016, 11:49:34 AM9/26/16
to openresty-en
Hello,

Is it possible to generate the Content-Length header in header_filter_by_lua ?
How to get the exact size of the response body like the following example?

thanks,

location = /now {
        chunked_transfer_encoding off
;
        content_by_lua_block
{
               
local buf = ngx.now()
               
--ngx.header["Content-Length"] = #tostring(buf)
                ngx
.print( buf )
       
}
        header_filter_by_lua_block
{
                ngx
.header["Content-Length"] = nil
       
}
}

Reply all
Reply to author
Forward
0 new messages