Fix minor typos in Server Sent Events lesson
This commit is contained in:
parent
71ff8f81b0
commit
e301bf3bd4
1 changed files with 3 additions and 3 deletions
|
@ -39,7 +39,7 @@ data: of two lines
|
|||
|
||||
- A message text goes after `data:`, the space after the colon is optional.
|
||||
- Messages are delimited with double line breaks `\n\n`.
|
||||
- To send a line break `\n`, we can immediately one more `data:` (3rd message above).
|
||||
- To send a line break `\n`, we can immediately send one more `data:` (3rd message above).
|
||||
|
||||
In practice, complex messages are usually sent JSON-encoded. Line-breaks are encoded as `\n` within them, so multiline `data:` messages are not necessary.
|
||||
|
||||
|
@ -102,7 +102,7 @@ data: Hello, I set the reconnection delay to 15 seconds
|
|||
|
||||
The `retry:` may come both together with some data, or as a standalone message.
|
||||
|
||||
The browser should wait that many milliseconds before reconnect. Or longer, e.g. if the browser knows (from OS) that there's no network connection at the moment, it may wait until the connection appears, and then retry.
|
||||
The browser should wait that many milliseconds before reconnecting. Or longer, e.g. if the browser knows (from OS) that there's no network connection at the moment, it may wait until the connection appears, and then retry.
|
||||
|
||||
- If the server wants the browser to stop reconnecting, it should respond with HTTP status 204.
|
||||
- If the browser wants to close the connection, it should call `eventSource.close()`:
|
||||
|
@ -113,7 +113,7 @@ let eventSource = new EventSource(...);
|
|||
eventSource.close();
|
||||
```
|
||||
|
||||
Also, there will be no reconnection if the response has an incorrect `Content-Type` or its HTTP status differs from 301, 307, 200 and 204. The connection the `"error"` event is emitted, and the browser won't reconnect.
|
||||
Also, there will be no reconnection if the response has an incorrect `Content-Type` or its HTTP status differs from 301, 307, 200 and 204. In such cases the `"error"` event will be emitted, and the browser won't reconnect.
|
||||
|
||||
```smart
|
||||
When a connection is finally closed, there's no way to "reopen" it. If we'd like to connect again, just create a new `EventSource`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue