diff --git a/src/emqx_auth_http_cli.erl b/src/emqx_auth_http_cli.erl index 25fac43..c56e45d 100644 --- a/src/emqx_auth_http_cli.erl +++ b/src/emqx_auth_http_cli.erl @@ -28,11 +28,11 @@ %%-------------------------------------------------------------------- request(PoolName, get, Path, Headers, Params, Timeout) -> - NewPath = Path ++ "?" ++ cow_qs:qs(bin_kw(Params)), + NewPath = Path ++ "?" ++ binary_to_list(cow_qs:qs(bin_kw(Params))), reply(emqx_http_client:request(get, PoolName, {NewPath, Headers}, Timeout)); request(PoolName, post, Path, Headers, Params, Timeout) -> - Body = case proplists:get_value(<<"content_type">>, Headers) of + Body = case proplists:get_value(<<"content-type">>, Headers) of <<"application/x-www-form-urlencoded">> -> cow_qs:qs(bin_kw(Params)); <<"application/json">> -> diff --git a/test/emqx_auth_http_SUITE.erl b/test/emqx_auth_http_SUITE.erl index 79c02c0..f9acdc6 100644 --- a/test/emqx_auth_http_SUITE.erl +++ b/test/emqx_auth_http_SUITE.erl @@ -66,13 +66,13 @@ set_special_configs(emqx, _Schmea, _Inet) -> set_special_configs(emqx_auth_http, Schema, Inet) -> ServerAddr = http_server(Schema, Inet), - AuthReq = #{method => get, + AuthReq = #{method => post, url => ServerAddr ++ "/mqtt/auth", - content_type => <<"application/x-www-form-urlencoded">>, + content_type => <<"application/json">>, params => [{"clientid", "%c"}, {"username", "%u"}, {"password", "%P"}]}, SuperReq = #{method => post, url => ServerAddr ++ "/mqtt/superuser", - content_type => <<"application/x-www-form-urlencoded">>, + content_type => <<"application/json">>, params => [{"clientid", "%c"}, {"username", "%u"}]}, AclReq = #{method => post, url => ServerAddr ++ "/mqtt/acl",