Subrequests from body filters
mdounin at mdounin.ru
Mon Mar 25 14:21:51 UTC 2013
On Mon, Mar 25, 2013 at 05:52:53PM +0400, Marat Dakota wrote:
> >> But is it ok to call next body filter in subrequest's body filter to
> >> produce output to main request?
> >> I mean ngx_http_next_body_filter(r->main, out).
> > No. You should call next body filter of the request you are
> > working with. It's postpone filter responsibility to manage
> > subrequests output, and if you try to do this yourself instead -
> > result will be undefined.
> It seems to work as expected for me. How can I cause problems with this?
Undefined behaviour sometimes appear to work as expected. This
doesn't mean it's correct though.
Depending on the exact place in a filter chain where you did it
and various other factors like timings, results may vary from
"nothing bad might happen, as r == r->main anyway" to "response
will completely incorrect as wrong filters will be applied to the
Most trivial thing to test is probably a subrequest order, which
likely will be wrong in your case if first subrequest will take
longer to handle than second one.
More information about the nginx-devel