Skip to content

Commit 19e7b4e

Browse files
chore: Updating README to include information on extended open event
1 parent d414d54 commit 19e7b4e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ In a browser that is using native `EventSource` the extra argument would simply
5656

5757
Like the standard `EventSource`, this implementation emits the event `open` when a stream has been started and `error` when a stream has failed for any reason. All events have a single parameter which is an instance of the `Event` class.
5858

59+
The `open` event has the following extended behavior: the event object will have a `headers` property which is an object representing the HTTP response headers received when opening the stream. For example:
60+
61+
```javascript
62+
{
63+
'content-type': 'text/event-stream; charset=utf-8',
64+
'transfer-encoding': 'chunked',
65+
'connection': 'close',
66+
'accept-ranges': 'bytes',
67+
'cache-control': 'no-cache, no-store, must-revalidate',
68+
}
69+
```
70+
5971
The `error` event has the following extended behavior: for an HTTP error response, the event object will have a `status` property (such as `401`) and optionally a `message` property (such as `"Unauthorized"`).
6072

6173
```javascript

0 commit comments

Comments
 (0)