fix chunked encoding API no response (#6157)

This commit is contained in:
hongming
2024-09-06 17:05:41 +08:00
committed by GitHub
parent 447a51f08b
commit 3c458b7450
2 changed files with 20 additions and 3 deletions

View File

@@ -420,7 +420,15 @@ func (c *ResponseCapture) Header() http.Header {
func (c *ResponseCapture) Write(data []byte) (int, error) {
c.WriteHeader(http.StatusOK)
c.body.Write(data)
return c.ResponseWriter.Write(data)
n, err := c.ResponseWriter.Write(data)
if err != nil {
return n, err
}
if flusher, ok := c.ResponseWriter.(http.Flusher); ok {
flusher.Flush()
}
return n, nil
}
func (c *ResponseCapture) WriteHeader(statusCode int) {