rewrite_by_lua precules header_filter_by_lua?

36 views
Skip to first unread message

David Birdsong

unread,
Feb 20, 2015, 9:39:19 PM2/20/15
to openresty-en
I'm calling ngx.set_uri('/foo'), false) but my header_filter_by_lua snippet doesn't appear to be called.

I'd understand if I was jumping to a new location, but is it expected that header_filters inside the same location would be ignored or am I doing something else wrong?

Yichun Zhang (agentzh)

unread,
Feb 21, 2015, 1:58:21 AM2/21/15
to openresty-en
Hello!

On Fri, Feb 20, 2015 at 6:39 PM, David Birdsong wrote:
> I'm calling ngx.set_uri('/foo'), false) but my header_filter_by_lua snippet
> doesn't appear to be called.
>

The ngx.req.set_uri('/foo', false) call only modifies the request URI
without doing any internal redirects, by definition.

header_filter_by_lua is only called when the current location is
generating a response header (note that even internal redirects do not
send response header themselves).

> I'd understand if I was jumping to a new location, but is it expected that
> header_filters inside the same location would be ignored or am I doing
> something else wrong?
>

Actually I'm confused by what you're really doing here. A minimal and
standalone example can be more helpful.

Regards,
-agentzh

David Birdsong

unread,
Feb 21, 2015, 2:22:49 PM2/21/15
to openre...@googlegroups.com
On Fri Feb 20 2015 at 10:58:22 PM Yichun Zhang (agentzh) <age...@gmail.com> wrote:
Hello!

On Fri, Feb 20, 2015 at 6:39 PM, David Birdsong wrote:
> I'm calling ngx.set_uri('/foo'), false) but my header_filter_by_lua snippet
> doesn't appear to be called.
>

The ngx.req.set_uri('/foo', false) call only modifies the request URI
without doing any internal redirects, by definition.

header_filter_by_lua is only called when the current location is
generating a response header (note that even internal redirects do not
send response header themselves).

> I'd understand if I was jumping to a new location, but is it expected that
> header_filters inside the same location would be ignored or am I doing
> something else wrong?
>

It turns out I was doing something else wrong. I emailed the list too soon.

I was able to modify the request URL without changing locations, proxy to the backend, and then modify headers before responding to the caller....all as expected.
 

Actually I'm confused by what you're really doing here. A minimal and
standalone example can be more helpful.

Regards,
-agentzh

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages