aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-02-27 13:02:28 +0100
committerLoïc Hoguin <[email protected]>2020-02-27 15:19:53 +0100
commit59d99d7d67fbab6db877ab9a6441b003490edfaa (patch)
tree46f935114d6f059d3e15a0a1d53fdc30f23df660
parentc236ed09726a4283a597f662307c9ac07e4f3b7a (diff)
downloadgun-59d99d7d67fbab6db877ab9a6441b003490edfaa.tar.gz
gun-59d99d7d67fbab6db877ab9a6441b003490edfaa.tar.bz2
gun-59d99d7d67fbab6db877ab9a6441b003490edfaa.zip
Add a test getting preface errors in the 'DOWN' reason
-rw-r--r--test/rfc7540_SUITE.erl22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 047e4bb..43d2e52 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -126,6 +126,28 @@ prior_knowledge_preface_http1(_) ->
error(timeout)
end.
+prior_knowledge_preface_http1_await(_) ->
+ doc("A PROTOCOL_ERROR connection error must result from the server sending "
+ "an invalid preface in the form of an HTTP/1.1 response when connecting "
+ "using the prior knowledge method. (RFC7540 3.4, RFC7540 3.5)"),
+ %% We are going to do the handshake manually.
+ {ok, _, Port} = do_init_origin(tcp, http, fun(_, Socket, Transport) ->
+ timer:sleep(100),
+ ok = Transport:send(Socket, <<
+ "HTTP/1.1 400 Bad Request\r\n"
+ "Connection: close\r\n"
+ "Content-Length: 0\r\n"
+ "Date: Thu, 27 Feb 2020 09:32:17 GMT\r\n"
+ "\r\n">>),
+ timer:sleep(100)
+ end),
+ {ok, ConnPid} = gun:open("localhost", Port, #{protocols => [http2], retry => 0}),
+ {ok, http2} = gun:await_up(ConnPid),
+ {error, {shutdown, {error, {connection_error, protocol_error,
+ 'Invalid connection preface received. (RFC7540 3.5)'}}}}
+ = gun:await(ConnPid, make_ref()),
+ gun:close(ConnPid).
+
prior_knowledge_preface_other_frame(_) ->
doc("A PROTOCOL_ERROR connection error must result from the server sending "
"an invalid preface in the form of a non-SETTINGS frame when connecting "