I want write a http hadler(using subrequest) to deal with combine
response from mutiple backend. but “Emiller’s Advanced Topics In Nginx
Module Development - 2.3. Sequential subrequests” issue that "
Subrequests
might need to access the network, and if so, Nginx needs to return to
its
other work while it waits for a response. So we need to check the return
value of ngx_http_subrequest"
How to write a Parallel subrequests which several subrequests by POST
in
parallel rather than one by one after received preivous response ?
thanks.
It is seem like that ngx_http_subrequest() supports only GET
method:
sr->method = NGX_HTTP_GET;
sr->http_version = r->http_version;
...............
sr->method_name = ngx_http_core_get_method;
In my application currently, NGINX received a POST request and issue
mutiple subrequests(Parallel) to get combine content by set proxy_pass
location, but ngx_http_subrequest() not supports POST method, so,
What
do I need to pay attention, if i just modify to :
sr->method = NGX_HTTP_POST
sr->http_version = r->http_version;
…
sr->method_name = r->method_name;
???
thanks a lot!
but ngx_http_subrequest() not supports POST method, so, What
do I need to pay attention, if i just modify to :
sr->method = NGX_HTTP_POST
sr->http_version = r->http_version;
…
sr->method_name = r->method_name;
???
Yeah, you can do something like that.
My Nginx modules ngx_echo, ngx_srcache, and ngx_lua all support custom
method names in their subrequests. See
On Thu, Dec 26, 2013 at 10:38:20AM -0500, honwel wrote:
Yes,you are right. But I want combine the data like:
Subrequst1’s response: “first name: John”
Subrequst2’s response: “last name: abc”
Excepting response:
“John abc”
In this particular example, using a filter module after the
postpone filter should be a good solution. It will see full
response concatenated by the postpone filter, and will be able
to transform it appropriately.
On Thu, Dec 26, 2013 at 11:21:42AM -0500, honwel wrote:
Excepting response:
“John abc”
Not
Response1:“John”
Response2:“abc”
Thanks for your patience!
Yes. What I suggested is to write a filter which will transform
Response1:“John”
Response2:“abc”
as available after the pospone filter to
“John abc”
you want to have as a result. This should be easier than writing
a filter which will also wait for all subrequests. If it doesn’t
work for you (e.g., if concatenation of subrequest responses isn’t
parsable), you may do subrequest serialization yourself, before
the postpone filter.