[dev] some questions about subrequests

Manlio Perillo manlio_perillo at libero.it
Sat Mar 29 15:18:36 MSK 2008

Sergey Bochenkov ha scritto:
> [...]
> If you need to keep the upstream response in memory,
> NGX_HTTP_SUBREQUEST_IN_MEMORY flag may be useful for you. You can
> also set the r->filter_need_in_memory flag in header-filter and read
> full response body in the body-filter.

Thanks, but I don't think I have the need to keep it in memory;
it will complicate the implementation.

>> I have one more, important, question.
>> When will be the post_subrequest->handler called?
>> Always after ngx_http_subrequest returns?
> The ngx_http_subrequest()-function is asyncronous and returns
> immediately after all appropriate fields of ngx_http_request_t
> structure will be filled. It doesn't wait for any upstream answer at
> all.
> The handler will be called after the end of the *subrequest*, not the
> end of ngx_http_subrequest()-function call.

The problem is that you are assuming that the subrequest will make use 
of the upstream module, but this is not always the case.

What happens if the subrequest will make use of the static module and 
the file is very small?

> Here you can find the appropriate discussion (unfortunately, in
> russian): http://article.gmane.org/gmane.comp.web.nginx.russian/11160

Thanks  Manlio Perillo

More information about the nginx mailing list