Hi,
I was wondering if this is a bug or not.
set $x 'true';
rewrite_by_lua '
ngx.var.x = "false"
ngx.log(ngx.NOTICE, "Value of x: ", ngx.var.x)
ngx.redirect("http://redirectedurl.com", 301)
';
The above configuration works and I get the notice in my log.
But when I move the redirect to the first line it stops working. Why is that?
set $x 'true';
rewrite_by_lua '
ngx.redirect("http://redirectedurl.com", 301)
ngx.var.x = "false"
ngx.log(ngx.NOTICE, "Value of x: ", ngx.var.x)
';
Note that this method call terminates the processing of the current request and that it must be called before ngx.send_headers or explicit response body outputs by either ngx.print or ngx.say.
It is recommended that a coding style that combines this method call with the
return
statement, i.e.,return ngx.redirect(...)
be adopted when this method call is used in contexts other than header_filter_by_lua to reinforce the fact that the request processing is being terminated.
--
You received this message because you are subscribed to a topic in the Google Groups "openresty-en" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openresty-en/fjJbH2V9-no/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.