mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
Replace bufio.Scanner with bufio.NewReaderSize + ReadBytes('\n') across all
SSE read paths to preserve long single-line data (e.g. write_file content).
Add quasi_status and auto_continue handling as direct path-based patches in
both Go continue observer and Node vercel_stream_impl, mirroring existing
batch-patch logic. Add 2MiB+ line throughput tests at every SSE layer.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
26 lines
376 B
Go
26 lines
376 B
Go
package protocol
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
func ScanSSELines(resp *http.Response, onLine func([]byte) bool) error {
|
|
reader := bufio.NewReaderSize(resp.Body, 64*1024)
|
|
for {
|
|
line, err := reader.ReadBytes('\n')
|
|
if len(line) > 0 {
|
|
if !onLine(line) {
|
|
return nil
|
|
}
|
|
}
|
|
if err != nil {
|
|
if err == io.EOF {
|
|
return nil
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
}
|