please help: How to remove content-length header?

39 views
Skip to first unread message

Diana Allende

unread,
Jun 14, 2021, 3:01:30 PMJun 14
to openre...@googlegroups.com
Hello all,

I understand from here https://github.com/openresty/lua-nginx-module#body_filter_by_lua that when the Lua code may change the length of the response body, then it is required to always clear out the Content-Length response header.

In my case I have a configuration like so inside location block
access_by_lua_block {
                require("my-lua-module").doSomething() -- this returns a response and exits
                }
Thus even if I have a block such as header_filter_by_lua_block { ngx.header.content_length = nil }, this code is never hit as there is an exit in the access_by_lua_block itself. Adding 
 ngx.header.content_length = nil to the beginning of access_by_lua_block doesn't work either.

As a result the content-length header is seen in the response which leads to errors such as 
Excess found in a read: excess = 1, size = 31, maxdownload = 31, bytecount = 0 (seen when curl request is issued)
Can someone please advise on how to overcome this?
Thanks for your help.

李俊龙

unread,
Jun 23, 2021, 8:12:13 PMJun 23
to openresty-en
remove content-length in header_filter_b_lua_block 

Kshitij Joshi

unread,
Jun 27, 2021, 12:36:08 PMJun 27
to openresty-en
you can also use more_clear_header
Reply all
Reply to author
Forward
0 new messages