fix: ReadEvent incompatible sse data format
This commit is contained in:
@@ -47,6 +47,12 @@ func (r *SSEReader) ReadEvent() (*SSEEvent, error) {
|
|||||||
return &SSEEvent{Data: []byte(jsonStr)}, nil
|
return &SSEEvent{Data: []byte(jsonStr)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 增强兼容性(data:后面没有紧接着一个空格)
|
||||||
|
if strings.HasPrefix(line, "data:") {
|
||||||
|
jsonStr := line[5:]
|
||||||
|
return &SSEEvent{Data: []byte(jsonStr)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// 其他行(如 event:, id: 等)跳过
|
// 其他行(如 event:, id: 等)跳过
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user