please help: How to remove content-length header?

Skip to first unread message

Diana Allende

Jun 14, 2021, 3:01:30 PMJun 14
Hello all,

I understand from here 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.


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

Kshitij Joshi

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