Hello!
On Tue, May 20, 2014 at 7:36 PM, bin al wrote:
> Thank you for your answer.
> I am interested in the cookies which would be used for the latter requests.
> Authentication information is required by one of the subrequests.
>
I've tried the following standalone example for the Set-Cookie headers
sent from the backend server, which works fine for me:
location = /fake { # fake backend
return 200 "ok";
add_header Set-Cookie foo;
add_header Set-Cookie bar;
}
location /t {
proxy_pass http://127.0.0.1:$server_port/fake;
}
location = /main {
content_by_lua '
local res1, res2 = ngx.location.capture_multi{
{ "/t1", {method=ngx.HTTP_POST}},
{ "/t2", {method=ngx.HTTP_GET}},
}
local concat = table.concat
for k, v in pairs(res1.header) do
if type(v) == "table" then
ngx.say(k, ": ", concat(v, ", "))
else
ngx.say(k, ": ", v)
end
end
';
}
Accessing /main gives:
$ curl localhost:8080/main
Content-Length: 2
Set-Cookie: foo, bar
Content-Type: text/plain
The major mistake in your original example is that you incorrectly
used ipairs() to traverse a hash table (instead of pairs()). Also,
your original example has so many syntax errors and I hope you will
copy&paste your tested configuration snippet the next time.
Best regards,
-agentzh