1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

simplify ReadBuffer

This commit is contained in:
Darien Raymond 2019-02-10 10:53:16 +01:00
parent b0a015c7cc
commit a84897b4b6
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -37,19 +37,8 @@ func ReadBuffer(r io.Reader) (*Buffer, error) {
if nBytes > 0 {
common.Must(b.WriteByte(firstByte[0]))
}
for i := 0; i < 64; i++ {
_, err := b.ReadFrom(r)
if !b.IsEmpty() {
b.ReadFrom(r)
return b, nil
}
if err != nil {
b.Release()
return nil, err
}
}
b.Release()
return nil, newError("Reader returns too many empty payloads.")
}
// BufferedReader is a Reader that keeps its internal buffer.