architecture of a module - processing a response from a subrequest

Mirko Dziadzka mirko.dziadzka at
Thu Jul 29 18:02:59 MSD 2010

Piotr Sikora wrote:
>> Question: What is the recommended way to read and process the response
>> body of a sub request which shouldn't go to the client? Should I use a
>> body-filter or can I access the response body from my post-subrequest
>> handler. I tried the later but it does not work. Any example code?
> Check eval module [1].

Thanks. I missed the NGX_HTTP_SUBREQUEST_IN_MEMORY flag in my first

What I don't understand: If I don't set NGX_HTTP_SUBREQUEST_IN_MEMORY,
then the response from the subrequest will be forwarded to the browser,
if I set NGX_HTTP_SUBREQUEST_IN_MEMORY flag, it will not. Is this the
supposed behavior or only a side effect.

A second question: I get the content of the response via

    if (r->upstream)
        ctx->response.len = r->upstream->buffer.last -
        ctx-> = r->upstream->buffer.pos;

Question: Will this buffer be available until the end of the main
request or do I have to make a copy here?



More information about the nginx-devel mailing list