diff options
author | Loïc Hoguin <[email protected]> | 2018-09-26 17:17:25 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-09-26 17:17:25 +0200 |
commit | 3c8e6cf819b1cebcf52cf385636d2136ec3677ee (patch) | |
tree | dc86be7473678ddfe6ab6cb9710435ae4dda6c58 /test/old_http_SUITE.erl | |
parent | 4493afbba0b4941117472f235c5fe152e75977da (diff) | |
download | cowboy-3c8e6cf819b1cebcf52cf385636d2136ec3677ee.tar.gz cowboy-3c8e6cf819b1cebcf52cf385636d2136ec3677ee.tar.bz2 cowboy-3c8e6cf819b1cebcf52cf385636d2136ec3677ee.zip |
Use gun:info instead of hacks for test socket operations
Diffstat (limited to 'test/old_http_SUITE.erl')
-rw-r--r-- | test/old_http_SUITE.erl | 27 |
1 files changed, 19 insertions, 8 deletions
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. |