fix: Prevent resource leaks by adding body close in stream handlers

This commit is contained in:
1808837298@qq.com
2025-03-05 19:51:22 +08:00
parent 37a83ecc33
commit 558e625a01
4 changed files with 7 additions and 4 deletions

View File

@@ -15,7 +15,10 @@ import (
)
func StreamScannerHandler(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo, dataHandler func(data string) bool) {
if resp == nil {
return
}
defer resp.Body.Close()
streamingTimeout := time.Duration(constant.StreamingTimeout) * time.Second
if strings.HasPrefix(info.UpstreamModelName, "o1") || strings.HasPrefix(info.UpstreamModelName, "o3") {
// twice timeout for thinking model