Add EventSource.fromReadableStream()#12272
Conversation
Allows developers use any ReadableStream source, such as from the fetch() API, while using EventSource for event-stream parsing. This separates networking concerns from parsing, enabling use cases like custom authentication or other headers, and allows application developers to handle their own reconnection behaviour. The lastEventId and reconnectionTime getters are added for use by applications in their own reconnection flows. The about:event-stream URL is defined for use as the URL for EventSource instances created from a ReadableStream.
|
These are some of the design decisions I made while writing this spec. Where possible, I preferred to keep the changes as simple for implementers as possible, reusing existing algorithms, with the goal of making it as easy as possible to be implemented. Defining Since there can't be any automatic reconnection and streams can't be reopened, it was easiest to have the connection fail when the stream ends. However, the custom reconnection use case can be handled by the application layer by using a Since the The The I considered different options for what this should return prior to the server sending its own I considered what to do with the Invoking |
Allows developers use any
ReadableStreamsource, such as from thefetch()API, while usingEventSourcefor event-stream parsing.This separates networking concerns from parsing, enabling use cases like custom authentication or other headers, and allows application developers to handle their own reconnection behaviour.
The
lastEventIdandreconnectionTimegetters are added for use by applications in their own reconnection flows.The
about:event-streamURL is defined for use as the URL forEventSourceinstances created from aReadableStream.Fixes #2177
(See WHATWG Working Mode: Changes for more details.)
/infrastructure.html ( diff )
/references.html ( diff )
/server-sent-events.html ( diff )
/urls-and-fetching.html ( diff )