encode: flush headers immediately for server-sent events responses (#7905)