Hello!
On Mon, Jan 11, 2016 at 11:11 PM, Robert Paprocki wrote:
> I've noticed that when calling ngx.exit() within a header_filter block, the
> filter seems to run multiple times. Given the following config:
>
> location /header-filter-test {
> header_filter_by_lua '
> ngx.log(ngx.INFO, "We are running in
> header_filter_by_lua!")
> ngx.exit(403)
> ';
> }
>
This is normal since using ngx.exit(403) in header_filter_by_lua*
initiate a "filter finalization", which in turn triggers the error
page handler to generate an error page response which has its own
header filter and body filter invocations.
> I do see the following note in the documentation:
>
> "When being used in the context of header_filter_by_lua, ngx.exit() is an asynchronous
> operation and will return immediately. This behavior may change in future and it is
> recommended that users always use return in combination as suggested above."
No, this piece is irrelevant since ngx.exit() call is always the
*last* statement of your header_filter_by_lua* handler.
Regards,
-agentzh