diff --git a/response_writer.go b/response_writer.go index 3e8f54f2..90ea4a0b 100644 --- a/response_writer.go +++ b/response_writer.go @@ -79,7 +79,9 @@ func (w *responseWriter) Written() bool { // Implements the http.Hijacker interface func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { - w.size = 0 // this prevents Gin to write the HTTP headers + if w.size < 0 { + w.size = 0 + } return w.ResponseWriter.(http.Hijacker).Hijack() } diff --git a/response_writer_test.go b/response_writer_test.go index 723acb0c..469388ab 100644 --- a/response_writer_test.go +++ b/response_writer_test.go @@ -15,6 +15,9 @@ import ( var _ ResponseWriter = &responseWriter{} var _ http.ResponseWriter = &responseWriter{} var _ http.ResponseWriter = ResponseWriter(&responseWriter{}) +var _ http.Hijacker = ResponseWriter(&responseWriter{}) +var _ http.Flusher = ResponseWriter(&responseWriter{}) +var _ http.CloseNotifier = ResponseWriter(&responseWriter{}) func init() { SetMode(TestMode)