aboutsummaryrefslogtreecommitdiffstats
path: root/test/gun_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/gun_SUITE.erl')
-rw-r--r--test/gun_SUITE.erl52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl
index 957d2df..dd7b083 100644
--- a/test/gun_SUITE.erl
+++ b/test/gun_SUITE.erl
@@ -28,6 +28,19 @@ all() ->
%% Tests.
+atom_header_name(_) ->
+ doc("Header names may be given as atom."),
+ {ok, OriginPid, OriginPort} = init_origin(tcp, http),
+ {ok, Pid} = gun:open("localhost", OriginPort),
+ {ok, http} = gun:await_up(Pid),
+ _ = gun:get(Pid, "/", [
+ {'User-Agent', "Gun/atom-headers"}
+ ]),
+ Data = receive_from(OriginPid),
+ Lines = binary:split(Data, <<"\r\n">>, [global]),
+ [<<"user-agent: Gun/atom-headers">>] = [L || <<"user-agent: ", _/bits>> = L <- Lines],
+ gun:close(Pid).
+
atom_hostname(_) ->
doc("Hostnames may be given as atom."),
{ok, OriginPid, OriginPort} = init_origin(tcp, http),
@@ -207,6 +220,32 @@ killed_streams_http(_) ->
error(timeout)
end.
+list_header_name(_) ->
+ doc("Header names may be given as list."),
+ {ok, OriginPid, OriginPort} = init_origin(tcp, http),
+ {ok, Pid} = gun:open("localhost", OriginPort),
+ {ok, http} = gun:await_up(Pid),
+ _ = gun:get(Pid, "/", [
+ {"User-Agent", "Gun/list-headers"}
+ ]),
+ Data = receive_from(OriginPid),
+ Lines = binary:split(Data, <<"\r\n">>, [global]),
+ [<<"user-agent: Gun/list-headers">>] = [L || <<"user-agent: ", _/bits>> = L <- Lines],
+ gun:close(Pid).
+
+map_headers(_) ->
+ doc("Header names may be given as a map."),
+ {ok, OriginPid, OriginPort} = init_origin(tcp, http),
+ {ok, Pid} = gun:open("localhost", OriginPort),
+ {ok, http} = gun:await_up(Pid),
+ _ = gun:get(Pid, "/", #{
+ <<"USER-agent">> => "Gun/map-headers"
+ }),
+ Data = receive_from(OriginPid),
+ Lines = binary:split(Data, <<"\r\n">>, [global]),
+ [<<"user-agent: Gun/map-headers">>] = [L || <<"user-agent: ", _/bits>> = L <- Lines],
+ gun:close(Pid).
+
reply_to(_) ->
doc("The reply_to option allows using a separate process for requests."),
do_reply_to(http),
@@ -396,3 +435,16 @@ do_unix_socket_connect() ->
after 250 ->
error(timeout)
end.
+
+uppercase_header_name(_) ->
+ doc("Header names may be given with uppercase characters."),
+ {ok, OriginPid, OriginPort} = init_origin(tcp, http),
+ {ok, Pid} = gun:open("localhost", OriginPort),
+ {ok, http} = gun:await_up(Pid),
+ _ = gun:get(Pid, "/", [
+ {<<"USER-agent">>, "Gun/uppercase-headers"}
+ ]),
+ Data = receive_from(OriginPid),
+ Lines = binary:split(Data, <<"\r\n">>, [global]),
+ [<<"user-agent: Gun/uppercase-headers">>] = [L || <<"user-agent: ", _/bits>> = L <- Lines],
+ gun:close(Pid).