Skip to content

Deleting Set-Cookie response header #37

@ghost

Description

ok, first - don't try to find a sense in this code - but it does not behave as it is expected:

i have a php-script which is used via fastcgi in nginx and will only execute this:

<?php
setcookie("TestCookie1", "foo");
setcookie("TestCookie2", "bar");

phpinfo();
?>

When using rewrite_by_lua_file with this code something unexpected happens:

if ngx.is_subrequest == false then

        ngx.header["Set-Cookie"] = {}
        res = ngx.location.capture(ngx.var.uri)

        for i,j in pairs(res.header) do ngx.header[i] = j end

        ngx.send_headers()
        ngx.print(res.body)

end

Normally i thought that the "for .. pairs"-part will write all response-headers from the subrequest into the ngx.header-table again. but in the Set-Cookie header only "TestCookie2" is received by the client which starts the request...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions