mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-06 09:25:27 +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>
27 lines
646 B
Go
27 lines
646 B
Go
package protocol
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestScanSSELinesHandlesLongSingleLine(t *testing.T) {
|
|
payload := strings.Repeat("x", 2*1024*1024+4096)
|
|
body := "data: {\"p\":\"response/content\",\"v\":\"" + payload + "\"}\n"
|
|
resp := &http.Response{Body: io.NopCloser(strings.NewReader(body))}
|
|
|
|
var got string
|
|
err := ScanSSELines(resp, func(line []byte) bool {
|
|
got = string(line)
|
|
return true
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("ScanSSELines returned error: %v", err)
|
|
}
|
|
if !strings.Contains(got, payload) {
|
|
t.Fatalf("long SSE line was not preserved: got len=%d want payload len=%d", len(got), len(payload))
|
|
}
|
|
}
|