Welcome! Log In Create A New Profile

Advanced

Re: ngx.location.capture_multi multiple posts

agentzh
June 20, 2012 02:34AM
Hello!

On Tue, Jun 19, 2012 at 10:23 PM, Matthias Rieber <ml-nginx@zu-con.org> wrote:
> I try to use ngx.location.capture_multi to send multiple post requests:
>
[...]
>      content_by_lua '
>        upstream_servers = {{"/server1", {copy_all_vars = true, method =
> ngx.HTTP_POST}},
>                            {"/server2", {copy_all_vars = true, method =
> ngx.HTTP_POST}},
>                            }

Here, you let the subrequests all inherit the request body of the
current request but one gotcha here is that the current request's body
can be consumed only once. So you have the following options:

1. Read the entire request body into memory or your custom file using
ngx_lua's ngx.req.get_body_data or ngx.req.get_body_file API, and then
feed that to your subrequest by specifying the "body" option value.

2. Read the request body in a streaming fashion by means of the
"downstream cosocket" object returned by ngx.req.socket(), and send
the data chunk received to multiple backend HTTP connections at the
same time by means of the "upstream cosocket" returned by
ngx.socket.tcp(). In this approach, you'll no longer use ngx_proxy.

Best regards,
-agentzh

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

ngx.location.capture_multi multiple posts

Matthias Rieber June 19, 2012 10:26AM

Re: ngx.location.capture_multi multiple posts

agentzh June 20, 2012 02:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready