aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/http_SUITE.erl6
-rw-r--r--test/old_http_SUITE.erl27
2 files changed, 21 insertions, 12 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 072190d..a8d3503 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -42,8 +42,7 @@ idle_timeout_infinity(Config) ->
Port = ranch:get_port(name()),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = gun:post(ConnPid, "/echo/read_body", [], <<"TEST">>),
- %% @todo Gun should have a debug function to retrieve the socket.
- Socket = element(11, element(2, sys:get_state(ConnPid))),
+ #{socket := Socket} = gun:info(ConnPid),
Pid = get_remote_pid_tcp(Socket),
Ref = erlang:monitor(process, Pid),
receive
@@ -61,8 +60,7 @@ request_timeout_infinity(Config) ->
}),
Port = ranch:get_port(name()),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
- %% @todo Gun should have a debug function to retrieve the socket.
- Socket = element(11, element(2, sys:get_state(ConnPid))),
+ #{socket := Socket} = gun:info(ConnPid),
Pid = get_remote_pid_tcp(Socket),
Ref = erlang:monitor(process, Pid),
receive
diff --git a/test/old_http_SUITE.erl b/test/old_http_SUITE.erl
index a1a23dd..8e31ec1 100644
--- a/test/old_http_SUITE.erl
+++ b/test/old_http_SUITE.erl
@@ -233,7 +233,7 @@ keepalive_nl(Config) ->
ConnPid = gun_open(Config),
Refs = [begin
Ref = gun:get(ConnPid, "/", [{<<"connection">>, <<"keep-alive">>}]),
- gun:dbg_send_raw(ConnPid, <<"\r\n">>),
+ dbg_send_raw(ConnPid, <<"\r\n">>),
Ref
end || _ <- lists:seq(1, 10)],
_ = [begin
@@ -538,7 +538,7 @@ te_chunked_chopped(Config) ->
Ref = gun:post(ConnPid, "/echo/body",
[{<<"content-type">>, <<"text/plain">>}]),
_ = [begin
- ok = gun:dbg_send_raw(ConnPid, << C >>),
+ ok = dbg_send_raw(ConnPid, << C >>),
receive after 10 -> ok end
end || << C >> <= Body2],
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
@@ -552,7 +552,7 @@ te_chunked_delayed(Config) ->
Ref = gun:post(ConnPid, "/echo/body",
[{<<"content-type">>, <<"text/plain">>}]),
_ = [begin
- ok = gun:dbg_send_raw(ConnPid, Chunk),
+ ok = dbg_send_raw(ConnPid, Chunk),
receive after 10 -> ok end
end || Chunk <- Chunks],
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
@@ -568,15 +568,15 @@ te_chunked_split_body(Config) ->
_ = [begin
case Chunk of
<<"0\r\n\r\n">> ->
- ok = gun:dbg_send_raw(ConnPid, Chunk);
+ ok = dbg_send_raw(ConnPid, Chunk);
_ ->
[Size, ChunkBody, <<>>] =
binary:split(Chunk, [<<"\r\n">>], [global]),
PartASize = random:uniform(byte_size(ChunkBody)),
<<PartA:PartASize/binary, PartB/binary>> = ChunkBody,
- ok = gun:dbg_send_raw(ConnPid, [Size, <<"\r\n">>, PartA]),
+ ok = dbg_send_raw(ConnPid, [Size, <<"\r\n">>, PartA]),
receive after 10 -> ok end,
- ok = gun:dbg_send_raw(ConnPid, [PartB, <<"\r\n">>])
+ ok = dbg_send_raw(ConnPid, [PartB, <<"\r\n">>])
end
end || Chunk <- Chunks],
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
@@ -593,9 +593,9 @@ te_chunked_split_crlf(Config) ->
%% Split in the newline just before the end of the chunk.
Len = byte_size(Chunk) - (random:uniform(2) - 1),
<< Chunk2:Len/binary, End/binary >> = Chunk,
- ok = gun:dbg_send_raw(ConnPid, Chunk2),
+ ok = dbg_send_raw(ConnPid, Chunk2),
receive after 10 -> ok end,
- ok = gun:dbg_send_raw(ConnPid, End)
+ ok = dbg_send_raw(ConnPid, End)
end || Chunk <- Chunks],
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
{ok, Body} = gun:await_body(ConnPid, Ref),
@@ -608,3 +608,14 @@ te_identity(Config) ->
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
{ok, Body} = gun:await_body(ConnPid, Ref),
ok.
+
+dbg_send_raw(ConnPid, Data) ->
+ #{
+ socket := Socket,
+ transport := Transport
+ } = gun:info(ConnPid),
+ _ = case Transport of
+ tcp -> gen_tcp:send(Socket, Data);
+ tls -> ssl:send(Socket, Data)
+ end,
+ ok.