fix: address responses SSE review feedback

This commit is contained in:
trph
2026-03-29 22:00:46 +08:00
parent 134a9eac9d
commit c03883ccf0
3 changed files with 55 additions and 40 deletions
@@ -26,13 +26,15 @@ func writeResponsesSSEChunk(w io.Writer, chunk []byte) {
if w == nil || len(chunk) == 0 {
return
}
_, _ = w.Write(chunk)
switch {
case bytes.HasSuffix(chunk, []byte("\n\n")):
if _, err := w.Write(chunk); err != nil {
return
case bytes.HasSuffix(chunk, []byte("\n")):
}
if bytes.HasSuffix(chunk, []byte("\n\n")) {
return
}
if bytes.HasSuffix(chunk, []byte("\n")) {
_, _ = w.Write([]byte("\n"))
default:
} else {
_, _ = w.Write([]byte("\n\n"))
}
}