fix: ReadEvent incompatible sse data format

main
moineye 2026-04-20 22:02:01 +08:00 committed by lyingbug
parent 09e1642335
commit 4ca0c7a644
1 changed files with 6 additions and 0 deletions

View File

@ -47,6 +47,12 @@ func (r *SSEReader) ReadEvent() (*SSEEvent, error) {
return &SSEEvent{Data: []byte(jsonStr)}, nil
}
// 增强兼容性(data:后面没有紧接着一个空格)
if strings.HasPrefix(line, "data:") {
jsonStr := line[5:]
return &SSEEvent{Data: []byte(jsonStr)}, nil
}
// 其他行(如 event:, id: 等)跳过
}