mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 07:43:29 +03:00
fix: implement Flush on trackingResponseWriter
Allows the trackingResponseWriter to properly proxy flush requests to the underlying http.Flusher. This ensures compatibility with streaming responses.
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/klauspost/compress/gzhttp"
|
||||
xhttp "github.com/minio/minio/internal/http"
|
||||
)
|
||||
|
||||
// Tests object location.
|
||||
@@ -159,6 +160,29 @@ func TestTrackingResponseWriter(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrackingResponseWriterFlush(t *testing.T) {
|
||||
rw := httptest.NewRecorder()
|
||||
trw := &trackingResponseWriter{ResponseWriter: rw}
|
||||
|
||||
trw.Flush()
|
||||
if trw.headerWritten {
|
||||
t.Fatal("Flush() should not set headerWritten")
|
||||
}
|
||||
|
||||
// Simulate the ListenNotificationHandler flow: WriteHeader, Write, Flush
|
||||
trw.WriteHeader(http.StatusOK)
|
||||
_, err := trw.Write([]byte("event data"))
|
||||
if err != nil {
|
||||
t.Fatalf("Write failed: %v", err)
|
||||
}
|
||||
|
||||
xhttp.Flush(trw)
|
||||
|
||||
if !rw.Flushed {
|
||||
t.Fatalf("xhttp.Flush should have flushed the underlying ResponseRecorder via trackingResponseWriter.Flush()")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHeadersAlreadyWritten(t *testing.T) {
|
||||
rw := httptest.NewRecorder()
|
||||
trw := &trackingResponseWriter{ResponseWriter: rw}
|
||||
|
||||
Reference in New Issue
Block a user