-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
The current logic in reader in Reader.more() is as follows:
<SNIP>
a, r.state = r.r.Read(r.data[len(r.data):cap(r.data)])
if a == 0 && r.state == nil {
r.state = io.ErrNoProgress
return
} else if a > 0 && r.state == io.EOF {
// discard the io.EOF if we read more than 0 bytes.
// the next call to Read should return io.EOF again.
r.state = nil
} else if r.state != nil {
return
}
r.data = r.data[:len(r.data)+a]
According to the io.Reader interface spec:
Callers should always process the n > 0 bytes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.
While this works correctly in the above code for io.EOF, it fails for any other error. So the returned bytes n > 0 from an io.Reader that also returns an error other than io.EOF will be ignore.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels