In some cases we were sending a response faster than h2spec was sending us the test case data, resulting in the request being processed successfully instead of failing as expected.
@@ -40,8 +40,8 @@ end_per_suite(_Config) ->
init_dispatch() ->
cowboy_router:compile([
- {"localhost", [
- {"/", hello_h, []}
+ {'_', [
+ {"/", delay_hello_h, 500}
]}
]).
@@ -0,0 +1,9 @@
+%% This module sends a hello world response after a delay.
+
+-module(delay_hello_h).
+-export([init/2]).
+init(Req, Delay) ->
+ timer:sleep(Delay),
+ {ok, cowboy_req:reply(200, #{}, <<"Hello world!">>, Req), Delay}.