aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-08-09 15:03:55 +0200
committerLoïc Hoguin <[email protected]>2018-08-09 15:03:55 +0200
commitf3149399815257b934ca5c47c9b9f2d9de198bc6 (patch)
tree7221cbe2f5de613162559531fd5e5c7fbec7de4b /test/handlers
parenta66484cf97db7ce3fc56b9e8f23b93a4e3da03ec (diff)
downloadgun-f3149399815257b934ca5c47c9b9f2d9de198bc6.tar.gz
gun-f3149399815257b934ca5c47c9b9f2d9de198bc6.tar.bz2
gun-f3149399815257b934ca5c47c9b9f2d9de198bc6.zip
Add an SSE test for lone id: lines
Diffstat (limited to 'test/handlers')
-rw-r--r--test/handlers/sse_lone_id_h.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/handlers/sse_lone_id_h.erl b/test/handlers/sse_lone_id_h.erl
new file mode 100644
index 0000000..3684fa9
--- /dev/null
+++ b/test/handlers/sse_lone_id_h.erl
@@ -0,0 +1,19 @@
+%% This module implements a loop handler that sends
+%% a lone id: line.
+
+-module(sse_lone_id_h).
+
+-export([init/2]).
+-export([info/3]).
+
+init(Req, State) ->
+ self() ! timeout,
+ {cowboy_loop, cowboy_req:stream_reply(200, #{
+ <<"content-type">> => <<"text/event-stream">>
+ }, Req), State}.
+
+info(timeout, Req, State) ->
+ cowboy_req:stream_events(#{
+ id => <<"hello">>
+ }, nofin, Req),
+ {stop, Req, State}.