Add WebAPIResponseEventStream for API streaming results.
Review Request #13281 — Created Sept. 21, 2023 and submitted
This builds upon the new
EventStreamHttpResponseclass to easily
enable APIs to stream events and results to callers using Server-Sent
WebAPIResourcehandlers can now return a generator or generator
function that yields messages for the event stream. These will be
serialized one-by-one using the same API response serialization logic we
otherwise use for the API. Callers can parse those as they come in,
X-Event-Data-Mimetypeheader to know the resource type for
any "message" events (the default when
eventisn't specified) to
intelligently handle parsing.
This can be used for HTTP GET/POST/PUT requests, making it possible to
stream progress notification or build a message bus using the API.
Unit tests pass.
Tested this with an
were properly coming in and could be parsed correctly.