Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gateway/src/resty/http_ng/backend/resty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ backend.send = function(_, request)
local httpc, err = http_proxy.new(request)

if err then
return nil, err
return response.error(request, err)
end

if httpc then
Expand Down
7 changes: 5 additions & 2 deletions spec/resty/http_ng/backend/resty_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ describe('resty backend', function()
local req = { method = method, url = 'http://0.0.0.0:0/' }
local response, err = backend:send(req)

assert.falsy(response)
assert.equal("connection refused", err)
assert.falsy(err)
assert.truthy(response.error)
assert.equal("connection refused", response.error)
assert.falsy(response.ok)
assert.same(req, response.request)
end)

context('http proxy is set', function()
Expand Down
8 changes: 4 additions & 4 deletions spec/resty/http_ng_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,18 @@ describe('http_ng', function()
end)

describe('when there is error #network', function()
local response, err
local response
before_each(function()
http = http_ng.new{ backend = resty_backend }
response, err = http.get('http://127.0.0.1:1')
response = http.get('http://127.0.0.1:1')
end)

it('is not ok', function()
assert.falsy(response)
assert.equal(false, response.ok)
end)

it('has error', function()
assert.equal("connection refused", err)
assert.equal("connection refused", response.error)
end)
end)

Expand Down