diff --git a/server.go b/server.go index dd8d5565..30dc7258 100644 --- a/server.go +++ b/server.go @@ -103,7 +103,7 @@ type Listener interface { } func transport(rw1, rw2 io.ReadWriter) error { - errc := make(chan error, 1) + errc := make(chan error, 2) go func() { errc <- copyBuffer(rw1, rw2) }() @@ -113,10 +113,17 @@ func transport(rw1, rw2 io.ReadWriter) error { }() err := <-errc + err2 := <-errc if err != nil && err == io.EOF { err = nil } - return err + if err != nil { + return err + } + if err2 != nil && err2 == io.EOF { + err2 = nil + } + return err2 } func copyBuffer(dst io.Writer, src io.Reader) error {