return the length of data written when the stream errors

This commit is contained in:
Marten Seemann
2017-06-14 12:08:26 +02:00
parent e1e076e375
commit c63be8c544
2 changed files with 18 additions and 1 deletions

View File

@@ -171,7 +171,7 @@ func (s *stream) Write(p []byte) (int, error) {
}
if s.err != nil {
return 0, s.err
return len(p) - len(s.dataForWriting), s.err
}
return len(p), nil