Skip to content

Commit 59ca824

Browse files
Allow CloseNotify() calls on the ResponseWriter wrapper to pass through.
1 parent e306dd7 commit 59ca824

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

responsewriter.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ func (w *responseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
8585
return nil, nil, fmt.Errorf("response writer (%T) does not implement http.Hijacker", w.base)
8686
}
8787

88+
// CloseNotify wraps the underlying CloseNotify or returns a dummy channel if the CloseNotifier interface is not implemented
89+
func (w *responseRecorder) CloseNotify() <-chan bool {
90+
if cn, ok := w.base.(http.CloseNotifier); ok {
91+
return cn.CloseNotify()
92+
}
93+
94+
// Return a dummy channel that will never get used
95+
return make(<-chan bool)
96+
}
97+
8898
// responseRecorderFlusher wraps a base http.ResponseWriter/http.Flusher allowing extraction of additional inspection data
8999
type responseRecorderFlusher struct {
90100
*responseRecorder

0 commit comments

Comments
 (0)