aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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}},