From 7df9b2b437f69855ceb86ca6a5bcec5427b2c59f Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Fri, 6 Jan 2017 15:57:09 +0200 Subject: [PATCH] net/http testing library doesnt supprots CloseNotify, so don't panic on context.StreamWriter --- response_writer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/response_writer.go b/response_writer.go index 794194f5..95dfd9c1 100644 --- a/response_writer.go +++ b/response_writer.go @@ -231,7 +231,11 @@ func (w *responseWriter) Flush() { // is a problem, use HTTP/2 or only use CloseNotify on methods // such as POST. func (w *responseWriter) CloseNotify() <-chan bool { - return w.ResponseWriter.(http.CloseNotifier).CloseNotify() + if notifier, supportsCloseNotify := w.ResponseWriter.(http.CloseNotifier); supportsCloseNotify { + return notifier.CloseNotify() + } + ch := make(chan bool, 1) + return ch } // clone returns a clone of this response writer