import (
"bufio"
- "bytes"
"errors"
"io"
"strconv"
if !r.eof {
return 0, errors.New("current chunk is unread")
}
- p, _ := r.r.Peek(21)
- if len(p) == 0 {
- return 0, io.EOF
- }
- idx := bytes.IndexByte(p, ':')
- if idx == -1 {
- return 0, errors.New("no length separator found")
- }
- size, err := strconv.ParseUint(string(p[:idx]), 10, 64)
+ lenRaw, err := r.r.ReadSlice(':')
if err != nil {
return 0, err
}
- if _, err = r.r.Discard(idx + 1); err != nil {
+ size, err := strconv.ParseUint(string(lenRaw[:len(lenRaw)-1]), 10, 64)
+ if err != nil {
return 0, err
}
r.left = size