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 13:02:28 +0100
commit85c1fea6ff5d82d3a6cdd8f13c9d292e4df90894 (patch)
tree35819615900e88df319fb5c7f1a442cd75707252
parent1bdc4fdb8f8634075944671ae00d14dadeba89df (diff)
downloadgun-85c1fea6ff5d82d3a6cdd8f13c9d292e4df90894.tar.gz
gun-85c1fea6ff5d82d3a6cdd8f13c9d292e4df90894.tar.bz2
gun-85c1fea6ff5d82d3a6cdd8f13c9d292e4df90894.zip
Add a test getting preface errors in the 'DOWN' reason
-rw-r--r--test/rfc7540_SUITE.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 780f850..76b4895 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -119,6 +119,29 @@ 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 use 'http' here because we are going to do the handshake manually.
+ {ok, OriginPid, Port} = 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),
+ handshake_completed = receive_from(OriginPid),
+ {error, {down, {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 "