2018-03-07 18:27:19 +01:00
|
|
|
%% This module implements a loop handler that does nothing
|
|
|
|
%% and expects a crash to happen.
|
|
|
|
|
|
|
|
-module(long_polling_sys_h).
|
|
|
|
|
|
|
|
-export([init/2]).
|
|
|
|
-export([info/3]).
|
|
|
|
-export([terminate/3]).
|
|
|
|
|
|
|
|
init(Req, _) ->
|
|
|
|
process_flag(trap_exit, true),
|
|
|
|
erlang:send_after(500, self(), timeout),
|
2018-03-23 18:33:16 +01:00
|
|
|
{cowboy_loop, Req, undefined}.
|
2018-03-07 18:27:19 +01:00
|
|
|
|
|
|
|
info(timeout, Req, State) ->
|
|
|
|
%% Send an unused status code to make sure there's no
|
|
|
|
%% conflict with whatever Cowboy may send itself.
|
|
|
|
{ok, cowboy_req:reply(<<"299 OK!">>, Req), State};
|
|
|
|
info(_, Req, State) ->
|
|
|
|
{ok, Req, State}.
|
|
|
|
|
2018-03-23 18:33:16 +01:00
|
|
|
terminate(_, _, _) ->
|
2018-03-07 18:27:19 +01:00
|
|
|
ok.
|