aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-06-25 15:56:29 +0200
committerLoïc Hoguin <[email protected]>2018-06-25 15:56:29 +0200
commitb2b5e3a01a1e02b79bcba330d11db693cd654c8f (patch)
treef8cff5b18c425901df5e22b7613c28451a8533c3 /src/cowboy_req.erl
parentf08f4610a08a187c573da2273494a27894bea54c (diff)
downloadcowboy-b2b5e3a01a1e02b79bcba330d11db693cd654c8f.tar.gz
cowboy-b2b5e3a01a1e02b79bcba330d11db693cd654c8f.tar.bz2
cowboy-b2b5e3a01a1e02b79bcba330d11db693cd654c8f.zip
Add an undocumented stream_events function
I will test it on a private project before settling on it.
Diffstat (limited to 'src/cowboy_req.erl')
-rw-r--r--src/cowboy_req.erl10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index d8fe70d..90b852e 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -80,7 +80,8 @@
-export([stream_reply/3]).
%% @todo stream_body/2 (nofin)
-export([stream_body/3]).
-%% @todo stream_event/2,3
+%% @todo stream_events/2 (nofin)
+-export([stream_events/3]).
-export([stream_trailers/2]).
-export([push/3]).
-export([push/4]).
@@ -786,6 +787,13 @@ stream_body(Data, IsFin, #{pid := Pid, streamid := StreamID, has_sent_resp := he
Pid ! {{Pid, StreamID}, {data, IsFin, Data}},
ok.
+-spec stream_events(cow_sse:event() | [cow_sse:event()], fin | nofin, req()) -> ok.
+stream_events(Event, IsFin, Req) when is_map(Event) ->
+ stream_events([Event], IsFin, Req);
+stream_events(Events, IsFin, #{pid := Pid, streamid := StreamID, has_sent_resp := headers}) ->
+ Pid ! {{Pid, StreamID}, {data, IsFin, cow_sse:events(Events)}},
+ ok.
+
-spec stream_trailers(cowboy:http_headers(), req()) -> ok.
stream_trailers(Trailers, #{pid := Pid, streamid := StreamID, has_sent_resp := headers}) ->
Pid ! {{Pid, StreamID}, {trailers, Trailers}},