Accessing subrequest output in memory
Eugaia
ngx.eugaia at gmail.com
Fri Oct 15 23:59:25 MSD 2010
Hi,
I'm trying to get the output of an in-memory subrequest, but I can't
find where the output is stored.
Basically, I'm doing :
...
ngx_uint_t flags;
ngx_http_post_subrequest_t *psr;
ngx_str_t location;
ngx_str_t *url_args;
psr->handler = my_callback;
flags |= NGX_HTTP_SUBREQUEST_IN_MEMORY;
ngx_http_subrequest (r, &location, url_args, &sr, psr, flags);
...
// waiting for for subrequest to process
my_callback (ngx_http_request_t *sr, void *data, ngx_int_t rc)
{
ngx_http_request_t *r;
r = sr->parent;
...
// I want to be able to access the (body) output from the
subrequest here
}
If the subrequest uses an upstream, I know I can access the output using
sr->upstream->buffer. However, if the subrequest does not use
upstreams, then this won't work. The output is not available from
sr->out - r->out is set to NULL at some point during the output
filtering. As far as I can make out, what I need to do is find where
the body output ngx_chain_t * struct is saved after all the body
filtering has been processed, but I'm struggling to find it.
Can anyone tell me where it is, or where I can find the output?
Note : I don't want to remove the in-memory flag because I don't want
the output flushed to the client.
Thanks,
Marcus.
More information about the nginx-devel
mailing list