Skip to content

Commit

Permalink
box: updated httpc error message
Browse files Browse the repository at this point in the history
Previously Tarantool used to raise the confusing error message in
case of invalid usage of the httpc module. Fixed to follow the
current module API.

Closes #4136
  • Loading branch information
kshcherbatov committed Apr 22, 2019
1 parent 5072227 commit 0ea3591
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lua/httpc.lua
Expand Up @@ -294,7 +294,7 @@ curl_mt = {
--
request = function(self, method, url, body, opts)
if not method or not url then
error('request(method, url [, options]])')
error('request(method, url [, body, [options]])')
end
local resp = self.curl:request(method, url, body, opts or {})
if resp and resp.headers then
Expand Down
6 changes: 5 additions & 1 deletion test/app-tap/http_client.test.lua
Expand Up @@ -62,10 +62,14 @@ local function stop_server(test, server)
end

local function test_http_client(test, url, opts)
test:plan(10)
test:plan(11)

test:isnil(rawget(_G, 'http'), "global namespace is not polluted");
test:isnil(rawget(_G, 'http.client'), "global namespace is not polluted");
local ok, err = pcall(client.request, client)
local usage_err = "request(method, url [, body, [options]])"
test:is_deeply({ok, tostring(err):split(': ')[2]}, {false, usage_err},
"test httpc usage")
local r = client.get(url, opts)
test:is(r.status, 200, 'simple 200')
test:is(r.reason, 'Ok', '200 - Ok')
Expand Down

0 comments on commit 0ea3591

Please sign in to comment.