Debian Codegraph @

test/handlers/long_polling_sys_h.erl

raw
1 %% This module implements a loop handler that does nothing
2 %% and expects a crash to happen.
3
4 -module(long_polling_sys_h).
5
6 -export([init/2]).
7 -export([info/3]).
8 -export([terminate/3]).
9
10 init(Req, _) ->
11 process_flag(trap_exit, true),
12 erlang:send_after(500, self(), timeout),
13 {cowboy_loop, Req, undefined}.
14
15 info(timeout, Req, State) ->
16 %% Send an unused status code to make sure there's no
17 %% conflict with whatever Cowboy may send itself.
18 {ok, cowboy_req:reply(<<"299 OK!">>, Req), State};
19 info(_, Req, State) ->
20 {ok, Req, State}.
21
22 terminate(_, _, _) ->
23 ok.