You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, it looks like we can detect the end of an event by scanning for two EOL characters. https://github.com/inaka/shotgun/blob/master/src/shotgun.erl#L624does do this, but it only looks for pairs of LF, when it should be looking for pairs of CR, LF, or CR/LF. Mightn't the following code at that line be more complete?
Tiny test from an Erlang shell is below. Note that the removal of any of the patterns in the call to binary:split causes at least one of the test SSEs to fail to have its trailing EOLs removed:
1> A= <<"test server side event\r\n\r\n">>.
<<"test server side event\r\n\r\n">>
2> B= <<"test server side event\r\r">>.
<<"test server side event\r\r">>
3> C= <<"test server side event\n\n">>.
<<"test server side event\n\n">>
4> lists:foldl(fun(F, A) -> lists:append(A, [binary:split(F, [<<"\r\r">>, <<"\n\n">>, <<"\r\n\r\n">>], [global])]) end, [], [A, B, C]).
[[<<"test server side event">>,<<>>],
[<<"test server side event">>,<<>>],
[<<"test server side event">>,<<>>]]
The text was updated successfully, but these errors were encountered:
@kennethlakin Your observation is spot on. There is an existing issue (#16) that reports this problem not only for the end of an event but for the different lines that are part of an event. I will close this issue and mark it as duplicated, we can address both problems in issue #16.
https://html.spec.whatwg.org/#parsing-an-event-stream specifies an SSE event as
So, it looks like we can detect the end of an event by scanning for two EOL characters. https://github.com/inaka/shotgun/blob/master/src/shotgun.erl#L624 does do this, but it only looks for pairs of LF, when it should be looking for pairs of CR, LF, or CR/LF. Mightn't the following code at that line be more complete?
Tiny test from an Erlang shell is below. Note that the removal of any of the patterns in the call to binary:split causes at least one of the test SSEs to fail to have its trailing EOLs removed:
The text was updated successfully, but these errors were encountered: