-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Current Issues
The Response.Flush() method in echo/response.go causes a panic if the http.ResponseWriter it wraps does not support the http.Flusher interface. The current panic message is “response writer flushing is not supported”, which makes it unclear which ResponseWriter type is causing the flushing to be unsupported. This may make debugging somewhat more difficult in the event of a problem.
Proposal
Change panic messages to include specific type information for ResponseWriters that do not support http.Flusher
import (
"bufio"
+"fmt"
"errors"
"net"
"net/http"
func (r *Response) Flush() {
err := http.NewResponseController(r.Writer).Flush()
if err != nil && errors.Is(err, http.ErrNotSupported) {
+panic(fmt.Errorf("echo: response writer %T does not support flushing (http.Flusher interface)", r.Writer))
}
}
Expected Effects
-
Improved debugging efficiency: When Flush is not supported, it becomes clear which ResponseWriter is the culprit, speeding problem identification and resolution.
-
Improved developer experience: More specific error information helps developers understand the cause of problems.