Add new cookie into headers_in

agentzh agentzh at gmail.com
Wed Jan 26 07:54:14 MSK 2011


>
> Sorry, it has nothing to do with ngx_headers_more, it's only related
> to the ngx_http_subrequest() function in the nginx core. My hack was
> not in the ngx_headers_more module, but in ngx_lua and ngx_echo. These
> modules adjust the subrequest struct when issuing a subrequest. My
> current way is not perfectly correct:
>
>    /* XXX work-around a bug in ngx_http_subrequest */
>    if (r->headers_in.headers.last == &r->headers_in.headers.part) {
>        sr->headers_in.headers.last = &sr->headers_in.headers.part;
>    }
>

Another pitfall with ngx_http_subrequest is that subrequests *share*
the whole variable value cache (i.e., r->variables) by default. That
means, if a subrequest modifies a variable, it will also affects the
parent, and vice versa. This often leads to very confusing
side-effects and bad results (which is very similar to how evil global
variables can be ;)). So I explicitly disable this behavior in the
subrequests issued by ngx_lua, ngx_echo, and ngx_srcache :)

Cheers,
-agentzh



More information about the nginx mailing list