Skip to content

Commit

Permalink
Support for chunked responses
Browse files Browse the repository at this point in the history
  • Loading branch information
subnetmarco committed Aug 10, 2015
1 parent 712b224 commit 2bdc780
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kong/cli/utils/ssl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function _M.prepare_ssl()
local file_name = os.tmpname()
local passphrase = utils.random_string()

local res, code = IO.os_execute([[
IO.os_execute([[
cd /tmp && \
openssl genrsa -des3 -out ]]..file_name..[[.key -passout pass:]]..passphrase..[[ 1024 && \
openssl req -new -key ]]..file_name..[[.key -out ]]..file_name..[[.csr -subj "/C=US/ST=California/L=San Francisco/O=Kong/OU=IT Department/CN=localhost" -passin pass:]]..passphrase..[[ && \
Expand Down
12 changes: 10 additions & 2 deletions kong/tools/http_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ local ltn12 = require "ltn12"

local _M = {}

local function get_response(resp)
if #resp == 0 then
return nil
else
return table.concat(resp, "")
end
end

local function http_call(options)
-- Set Host header accordingly
local parsed_url = url.parse(options.url)
Expand All @@ -28,10 +36,10 @@ local function http_call(options)
options.options = "all"

local _, code, headers = https.request(options)
return resp[1], code, headers
return get_response(resp), code, headers
else
local _, code, headers = http.request(options)
return resp[1], code, headers
return get_response(resp), code, headers
end
end

Expand Down
2 changes: 0 additions & 2 deletions spec/integration/cli/restart_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local IO = require "kong.tools.io"
local spec_helper = require "spec.spec_helpers"

describe("CLI", function()
Expand Down Expand Up @@ -26,7 +25,6 @@ describe("CLI", function()
end)

it("should restart kong when it's crashed", function()
local kong_pid = IO.read_file(spec_helper.get_env().configuration.pid_file)
os.execute("pkill -9 nginx")

local res, code = spec_helper.restart_kong()
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/proxy/dns_resolver_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("DNS", function()
describe("DNS", function()

it("should work when calling local IP", function()
local thread = spec_helper.start_tcp_server(TCP_PORT) -- Starting the mock TCP server
local thread = spec_helper.start_http_server(TCP_PORT) -- Starting the mock TCP server

local _, status = http_client.get(spec_helper.STUB_GET_URL, nil, { host = "dns1.com" })
assert.are.equal(200, status)
Expand All @@ -33,7 +33,7 @@ describe("DNS", function()
end)

it("should work when calling local hostname", function()
local thread = spec_helper.start_tcp_server(TCP_PORT) -- Starting the mock TCP server
local thread = spec_helper.start_http_server(TCP_PORT) -- Starting the mock TCP server

local _, status = http_client.get(spec_helper.STUB_GET_URL, nil, { host = "dns2.com" })
assert.are.equal(200, status)
Expand Down

0 comments on commit 2bdc780

Please sign in to comment.