Skip to content

Commit

Permalink
add test to make sure duplocate headers issue is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Mar 1, 2017
1 parent 65597e0 commit 51c5dd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
{top_level_readme,
{"./README.md", "http://github.com/benoitc/hackney"}}]}]},
{test, [
{deps, [{cowboy, "1.0.4"}]}
{deps, [{cowboy, "1.0.4"}, {jsone, "1.4.3"}]}
]}
]}.
16 changes: 15 additions & 1 deletion test/hackney_integration_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ all_tests() ->
absolute_redirect_request_follow(),
relative_redirect_request_no_follow(),
relative_redirect_request_follow(),
test_duplicate_headers(),
async_request(),
async_head_request(),
async_no_content_request()].

%%all_tests() ->
%% case has_unix_socket() of
%% true -> default_tests() ++ [local_socket_request()];
%% true -> def
%% ault_tests() ++ [local_socket_request()];
%% false -> default_tests()
%% end.

Expand Down Expand Up @@ -150,6 +152,18 @@ async_no_content_request() ->
[?_assertEqual(204, StatusCode),
?_assertEqual([headers, status], Keys)].

test_duplicate_headers() ->
URL = <<"http://localhost:8000/post">>,
Headers = [{<<"Content-Type">>, <<"application/json">>}],
Body = <<"{\"test\": \"ok\" }">>,
Options = [with_body],
{ok, 200, _H, JsonBody} = hackney:post(URL, Headers, Body, Options),
Obj = jsone:decode(JsonBody, [{object_format, proplist}]),
ReqHeaders = proplists:get_value(<<"headers">>, Obj),
?_assertEqual(<<"application/json">>, proplists:get_value(<<"Content-Type">>, ReqHeaders)).



%%local_socket_request() ->
%% URL = <<"http+unix://httpbin.sock/get">>,
%% {ok, StatusCode, _, _} = hackney:request(get, URL, [], <<>>, []),
Expand Down

0 comments on commit 51c5dd8

Please sign in to comment.