How to make a post subrequest with response body from parent?.

edo888 nginx-forum at nginx.us
Mon Feb 27 01:15:24 UTC 2012


Digging around I was able to get this code so far:

in my module's body filter I do this:

if(ngx_http_subrequest(r, &uri, &query_string, &sr, NULL, 0) != NGX_OK)
        return NGX_ERROR;

// adjust subrequest
ngx_str_t method_name = ngx_string("POST");
sr->method = NGX_HTTP_POST;
sr->method_name = method_name;


First of all it still uses GET with fastcgi_pass. If I do proxy_pass
instead the method is POST. I think it is a bug in fastcgi module. The
above code should be OK so far, since it works with proxy_pass.

Now I don't know how to pass post data to subrequest. I have tried to
create a buffer chain with sample data in it and using
sr->request_body->bufs, however it doesn't work.

Am I right that if I populate sr->request_body->bufs they will be
written to subrequest request body?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222983,223023#msg-223023



More information about the nginx mailing list