diff --git a/distributions/.build-package-script.sh b/distributions/.build-package-script.sh index 3a028974cab3..ee81499176b9 100755 --- a/distributions/.build-package-script.sh +++ b/distributions/.build-package-script.sh @@ -190,7 +190,11 @@ tar xzf LuaJIT-$LUAJIT_VERSION.tar.gz cd LuaJIT-$LUAJIT_VERSION make make install DESTDIR=$OUT -sudo make install # Install also on the build system +if [ "$(uname)" = "Darwin" ]; then + sudo make install +else + make install # Install also on the build system +fi cd $OUT # Install LuaRocks diff --git a/kong/cli/utils/signal.lua b/kong/cli/utils/signal.lua index c74786b78e88..c246b2fcc43c 100644 --- a/kong/cli/utils/signal.lua +++ b/kong/cli/utils/signal.lua @@ -312,7 +312,7 @@ function _M.send_signal(args_config, signal) if signal == STOP and success then if IO.file_exists(kong_config.pid_file) then - os.execute("while [ -f "..kong_config.pid_file.." ]; do sleep 0.1; done") + os.execute("while [ -f "..kong_config.pid_file.." ]; do sleep 0.5; done") end end diff --git a/kong/plugins/response_transformer/body_filter.lua b/kong/plugins/response_transformer/body_filter.lua index 8cc0cdb69728..985d1c7dd015 100644 --- a/kong/plugins/response_transformer/body_filter.lua +++ b/kong/plugins/response_transformer/body_filter.lua @@ -63,11 +63,11 @@ function _M.execute(conf) local is_json_body = get_content_type() == APPLICATION_JSON - if (conf.add.json or conf.remove.json) and is_json_body then + if ((conf.add and conf.add.json) or (conf.remove and conf.remove.json)) and is_json_body then local json_body = read_json_body() if json_body then - if conf.add.json then + if conf.add and conf.add.json then iterate_and_exec(conf.add.json, function(name, value) local v = cjson.encode(value) if stringy.startswith(v, "\"") and stringy.endswith(v, "\"") then @@ -77,7 +77,7 @@ function _M.execute(conf) end) end - if conf.remove.json then + if conf.remove and conf.remove.json then iterate_and_exec(conf.remove.json, function(name) json_body[name] = nil end) diff --git a/spec/plugins/response_transformer.lua b/spec/plugins/response_transformer_spec.lua similarity index 82% rename from spec/plugins/response_transformer.lua rename to spec/plugins/response_transformer_spec.lua index e1159bd1245d..3086a787c70a 100644 --- a/spec/plugins/response_transformer.lua +++ b/spec/plugins/response_transformer_spec.lua @@ -13,6 +13,7 @@ describe("Response Transformer Plugin #proxy", function() spec_helper.insert_fixtures { api = { { name = "tests response_transformer", public_dns = "response.com", target_url = "http://httpbin.org" }, + { name = "tests response_transformer 2", public_dns = "response2.com", target_url = "http://httpbin.org" }, }, plugin_configuration = { { @@ -28,6 +29,15 @@ describe("Response Transformer Plugin #proxy", function() } }, __api = 1 + }, + { + name = "response_transformer", + value = { + add = { + headers = {"Cache-Control:max-age=86400"} + } + }, + __api = 2 } } } @@ -62,8 +72,14 @@ describe("Response Transformer Plugin #proxy", function() assert.are.equal("newvalue", body["newjsonparam"]) end) + it("should add new headers", function() + local body, status, headers = http_client.get(STUB_GET_URL, {}, {host = "response2.com"}) + assert.are.equal(200, status) + assert.are.equal("max-age=86400", headers["cache-control"]) + end) + end) - + describe("Test removing parameters", function() it("should remove a header", function() @@ -80,5 +96,5 @@ describe("Response Transformer Plugin #proxy", function() end) end) - + end)