aboutsummaryrefslogtreecommitdiffstats
path: root/test/rfc7540_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-03-13 23:14:57 +0100
committerLoïc Hoguin <[email protected]>2016-03-13 23:14:57 +0100
commit3969c318242a84923186f3bb2f7246363bec9a1b (patch)
tree4315d0436430e5eac2cd1a7a54b0c5da5782f5e9 /test/rfc7540_SUITE.erl
parent2620d65fdef81dc88916a2b76764a3cf700a7cc1 (diff)
downloadcowboy-3969c318242a84923186f3bb2f7246363bec9a1b.tar.gz
cowboy-3969c318242a84923186f3bb2f7246363bec9a1b.tar.bz2
cowboy-3969c318242a84923186f3bb2f7246363bec9a1b.zip
Fix most remaining HTTP/2 handshake tests
One category of tests involving the SETTINGS ack still fails. It is probably wise to leave these until more SETTINGS related tests are written.
Diffstat (limited to 'test/rfc7540_SUITE.erl')
-rw-r--r--test/rfc7540_SUITE.erl47
1 files changed, 43 insertions, 4 deletions
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 2c75fe1..b560d02 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -202,6 +202,11 @@ http_upgrade_client_preface_timeout(Config) ->
%% Receive the server preface.
{ok, << Len:24 >>} = gen_tcp:recv(Socket, 3, 1000),
{ok, << 4:8, 0:40, _:Len/binary >>} = gen_tcp:recv(Socket, 6 + Len, 1000),
+ %% Receive the response to the initial HTTP/1.1 request.
+ {ok, << HeadersSkipLen:24, 1:8, _:8, 1:32 >>} = gen_tcp:recv(Socket, 9, 1000),
+ {ok, _} = gen_tcp:recv(Socket, HeadersSkipLen, 1000),
+ {ok, << DataSkipLen:24, 0:8, _:8, 1:32 >>} = gen_tcp:recv(Socket, 9, 1000),
+ {ok, _} = gen_tcp:recv(Socket, DataSkipLen, 1000),
%% Do not send the preface. Wait for the server to disconnect us.
{error, closed} = gen_tcp:recv(Socket, 9, 6000),
ok.
@@ -224,8 +229,25 @@ http_upgrade_reject_missing_client_preface(Config) ->
{ok, << Len:24 >>} = gen_tcp:recv(Socket, 3, 1000),
{ok, << 4:8, 0:40, _:Len/binary >>} = gen_tcp:recv(Socket, 6 + Len, 1000),
%% We expect the server to close the connection when it receives a bad preface.
- {error, closed} = gen_tcp:recv(Socket, 9, 1000),
- ok.
+ %% The server may however have already started sending the response to the
+ %% initial HTTP/1.1 request.
+ Received = lists:reverse(lists:foldl(fun(_, Acc) ->
+ case gen_tcp:recv(Socket, 9, 1000) of
+ {ok, << SkipLen:24, 1:8, _:8, 1:32 >>} ->
+ {ok, _} = gen_tcp:recv(Socket, SkipLen, 1000),
+ [headers|Acc];
+ {ok, << SkipLen:24, 0:8, _:8, 1:32 >>} ->
+ {ok, _} = gen_tcp:recv(Socket, SkipLen, 1000),
+ [data|Acc];
+ {error, _} ->
+ [closed|Acc]
+ end
+ end, [], [1, 2, 3])),
+ case Received of
+ [closed|_] -> ok;
+ [headers, closed|_] -> ok;
+ [headers, data, closed] -> ok
+ end.
http_upgrade_reject_invalid_client_preface(Config) ->
doc("Servers must treat an invalid connection preface as a "
@@ -283,8 +305,25 @@ http_upgrade_reject_missing_client_preface_settings(Config) ->
{ok, << Len:24 >>} = gen_tcp:recv(Socket, 3, 1000),
{ok, << 4:8, 0:40, _:Len/binary >>} = gen_tcp:recv(Socket, 6 + Len, 1000),
%% We expect the server to close the connection when it receives a bad preface.
- {error, closed} = gen_tcp:recv(Socket, 9, 1000),
- ok.
+ %% The server may however have already started sending the response to the
+ %% initial HTTP/1.1 request.
+ Received = lists:reverse(lists:foldl(fun(_, Acc) ->
+ case gen_tcp:recv(Socket, 9, 1000) of
+ {ok, << SkipLen:24, 1:8, _:8, 1:32 >>} ->
+ {ok, _} = gen_tcp:recv(Socket, SkipLen, 1000),
+ [headers|Acc];
+ {ok, << SkipLen:24, 0:8, _:8, 1:32 >>} ->
+ {ok, _} = gen_tcp:recv(Socket, SkipLen, 1000),
+ [data|Acc];
+ {error, _} ->
+ [closed|Acc]
+ end
+ end, [], [1, 2, 3])),
+ case Received of
+ [closed|_] -> ok;
+ [headers, closed|_] -> ok;
+ [headers, data, closed] -> ok
+ end.
http_upgrade_reject_invalid_client_preface_settings(Config) ->
doc("Servers must treat an invalid connection preface as a "