diff options
author | Loïc Hoguin <[email protected]> | 2018-11-16 13:09:01 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-16 13:09:01 +0100 |
commit | 75045637fc6026054900f2dbea75805ad7c8e682 (patch) | |
tree | a7d426e8a463de52127981758e6e6624c30b609c /test | |
parent | 1949357f0cbcc1e6c94add457c7cad90d35340c1 (diff) | |
download | cowboy-75045637fc6026054900f2dbea75805ad7c8e682.tar.gz cowboy-75045637fc6026054900f2dbea75805ad7c8e682.tar.bz2 cowboy-75045637fc6026054900f2dbea75805ad7c8e682.zip |
Ensure unknown options are ignored in set_options command
Diffstat (limited to 'test')
-rw-r--r-- | test/handlers/stream_handler_h.erl | 6 | ||||
-rw-r--r-- | test/stream_handler_SUITE.erl | 18 |
2 files changed, 24 insertions, 0 deletions
diff --git a/test/handlers/stream_handler_h.erl b/test/handlers/stream_handler_h.erl index 2196be3..3761e11 100644 --- a/test/handlers/stream_handler_h.erl +++ b/test/handlers/stream_handler_h.erl @@ -34,6 +34,12 @@ init_commands(_, _, #state{test=crash_in_terminate}) -> [{response, 200, #{<<"content-length">> => <<"12">>}, <<"Hello world!">>}, stop]; init_commands(_, _, #state{test=crash_in_early_error}) -> error(crash); +init_commands(_, _, #state{test=set_options_ignore_unknown}) -> + [ + {set_options, #{unknown_options => true}}, + {response, 200, #{<<"content-length">> => <<"12">>}, <<"Hello world!">>}, + stop + ]; init_commands(_, _, State=#state{test=shutdown_on_stream_stop}) -> Spawn = init_process(false, State), [{headers, 200, #{}}, {spawn, Spawn, 5000}, stop]; diff --git a/test/stream_handler_SUITE.erl b/test/stream_handler_SUITE.erl index 738a4a2..0021ab9 100644 --- a/test/stream_handler_SUITE.erl +++ b/test/stream_handler_SUITE.erl @@ -224,6 +224,24 @@ do_crash_in_early_error_fatal(Config) -> %% Confirm the connection gets closed. gun_down(ConnPid). +set_options_ignore_unknown(Config) -> + doc("Confirm that unknown options are ignored when using the set_options commands."), + Self = self(), + ConnPid = gun_open(Config), + Ref = gun:get(ConnPid, "/long_polling", [ + {<<"accept-encoding">>, <<"gzip">>}, + {<<"x-test-case">>, <<"set_options_ignore_unknown">>}, + {<<"x-test-pid">>, pid_to_list(Self)} + ]), + %% Confirm init/3 is called. + Pid = receive {Self, P, init, _, _, _} -> P after 1000 -> error(timeout) end, + %% Confirm terminate/3 is called, indicating the stream ended. + receive {Self, Pid, terminate, _, _, _} -> ok after 1000 -> error(timeout) end, + %% Confirm the response is sent. + {response, nofin, 200, _} = gun:await(ConnPid, Ref), + {ok, _} = gun:await_body(ConnPid, Ref), + ok. + shutdown_on_stream_stop(Config) -> doc("Confirm supervised processes are shutdown when stopping the stream."), Self = self(), |