Fix the SSE endpoint's Content-Type so GeckoView actually receives updates #6
Loading…
Reference in a new issue
No description provided.
Delete branch "sse-correct-content-type"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported: the TV never auto-updates scores, even though
/events(theServer-Sent Events endpoint driving the live scoreboard) worked fine in
Chromium and desktop Firefox during earlier testing this session.
Bug
/eventswas sendingContent-Type: text/plaininstead oftext/event-stream. Confirmed directly withcurl -Iagainst the liveendpoint - this was a real, pre-existing bug in the app, not a guess.
Per the WHATWG EventSource spec, the user agent must fail the connection
if the response's MIME type isn't exactly
text/event-stream. Chromium islenient about this in practice and processes the stream anyway; that
leniency is almost certainly why every desktop test in this session looked
fine while the actual TV - GeckoView, which enforces the spec correctly -
silently never got a working connection at all.
Fix
Changed
mimetype='text/plain'tocontent_type='text/event-stream'(notmimetype=, which would let Flask auto-append; charset=utf-8-unnecessary on this content type and one more way to hand a picky
implementation a content-type it won't match exactly).
Testing
Verified locally: the response now sends
Content-Type: text/event-streamwith no charset param, and the stream still delivers the same
data: [...]payload as before.