Skip to content
This repository has been archived by the owner on Dec 11, 2018. It is now read-only.

match against ok and close instead of crashing on close #79

Merged
merged 2 commits into from
Dec 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/bullet_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ reply_get_mode(eventsource, Data, Req) ->
Bin = iolist_to_binary(Data),
Event = [[<<"data: ">>, Line, <<"\n">>] ||
Line <- binary:split(Bin, [<<"\r\n">>, <<"\r">>, <<"\n">>], [global])],
ok = cowboy_req:chunk([Event, <<"\n">>], Req),
{loop, Req}.
case cowboy_req:chunk([Event, <<"\n">>], Req) of
ok -> {loop, Req};
close -> {ok, Req};
{error, closed} -> {ok, Req}
end.

%% Internal.

Expand Down