fix: [2.5][RESTFUL] Return error when writer body closed (#41184)

Cherry-pick from master
pr: #41183
Related to #41181

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/41221/head
congqixia 2025-04-09 19:37:09 +08:00 committed by GitHub
parent 77e6404617
commit 7001474914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import (
"sync"
"time"
"github.com/cockroachdb/errors"
"github.com/gin-gonic/gin"
mhttp "github.com/milvus-io/milvus/internal/http"
@ -81,7 +82,7 @@ func NewWriter(w gin.ResponseWriter, buf *bytes.Buffer) *Writer {
// Write will write data to response body
func (w *Writer) Write(data []byte) (int, error) {
if w.timeout || w.body == nil {
return 0, nil
return 0, errors.New("Response writer closed")
}
w.mu.Lock()