Ignore Read error if we read enough data.

This commit is contained in:
Vladimir Mihailenco 2012-10-26 18:21:57 +03:00
parent 096f017b69
commit 9e8b988406
1 changed files with 7 additions and 3 deletions

View File

@ -73,12 +73,16 @@ func readN(rd reader, n int) ([]byte, error) {
r := copy(newBuf, buf)
buf = newBuf
for r < n {
n, err := rd.Read(buf[r:])
for {
nn, err := rd.Read(buf[r:])
r += nn
if r >= n {
// Ignore error if we read enough.
break
}
if err != nil {
return nil, err
}
r += n
}
} else if err != nil {
return nil, err