Commit 528588d
committed
SEP-1699: Support SSE polling via server-side disconnect
This implements the specification changes for SEP-1699:
* When a server starts an SSE stream, it MUST immediately send an SSE
event consisting of an [`id`][SSE `id`] and an empty
[`data`][SSE `data`] string in order to prime the client to reconnect
with that event ID as the `Last-Event-ID`.
Note that the SSE standard explicitly [permits setting `data` to an empty string][SSE empty `data`],
and says that the appropriate client-side handling is to record the
`id` for `Last-Event-ID` but otherwise ignore the event (i.e., not
call the event handler callback).
* At any point after the server has sent an event ID to the client, the
server MAY disconnect at will.
* If a server disconnects, the client will interpret the disconnection
the same as a network failure, and will attempt to reconnect. In
order to prevent clients from reconnecting / polling excessively, the
server SHOULD send an SSE event with a [`retry`][SSE `retry`] field
indicating how long the client should wait before reconnecting.
Clients MUST respect the `retry` field.
[SSE `id`]: https://html.spec.whatwg.org/multipage/server-sent-events.html#:~:text=field%20name%20is%20%22id%22
[SSE `data`]: https://html.spec.whatwg.org/multipage/server-sent-events.html#:~:text=field%20name%20is%20%22data%22
[SSE empty `data`]: https://html.spec.whatwg.org/multipage/server-sent-events.html#:~:text=data%20buffer%20is%20an%20empty%20string
[SSE `retry`]: https://html.spec.whatwg.org/multipage/server-sent-events.html#:~:text=field%20name%20is%20%22retry%221 parent d847a00 commit 528588d
2 files changed
+16
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
107 | 118 | | |
108 | 119 | | |
109 | 120 | | |
110 | 121 | | |
111 | | - | |
112 | | - | |
| 122 | + | |
113 | 123 | | |
114 | | - | |
115 | | - | |
| 124 | + | |
| 125 | + | |
116 | 126 | | |
117 | 127 | | |
118 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
0 commit comments