fix: resolve "bufio.Scanner: token too long" error by increasing buffer size

This commit is contained in:
QistChan 2025-02-24 01:59:54 +08:00 committed by GitHub
parent 8df4a2670b
commit 706aa7233b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,6 +27,8 @@ const (
func StreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*model.ErrorWithStatusCode, string, *model.Usage) { func StreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*model.ErrorWithStatusCode, string, *model.Usage) {
responseText := "" responseText := ""
scanner := bufio.NewScanner(resp.Body) scanner := bufio.NewScanner(resp.Body)
buffer := make([]byte, 256*1024)
scanner.Buffer(buffer, len(buffer))
scanner.Split(bufio.ScanLines) scanner.Split(bufio.ScanLines)
var usage *model.Usage var usage *model.Usage