From 248389b3f6cfe08abb4940ad0bc978a6b8da0fcc Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Sun, 12 Apr 2020 16:34:49 +0100 Subject: [PATCH] Make WriteTo return the correct errors --- internal/multiplex/stream.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/multiplex/stream.go b/internal/multiplex/stream.go index 0350d31..d419380 100644 --- a/internal/multiplex/stream.go +++ b/internal/multiplex/stream.go @@ -83,7 +83,12 @@ func (s *Stream) Read(buf []byte) (n int, err error) { func (s *Stream) WriteTo(w io.Writer) (int64, error) { // will keep writing until the underlying buffer is closed - return s.recvBuf.WriteTo(w) + n, err := s.recvBuf.WriteTo(w) + if err == io.EOF { + return n, ErrBrokenStream + } + log.Tracef("%v read from stream %v with err %v", n, s.id, err) + return n, nil } // Write implements io.Write