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:
parent
b0a015c7cc
commit
a84897b4b6
@ -37,19 +37,8 @@ func ReadBuffer(r io.Reader) (*Buffer, error) {
|
|||||||
if nBytes > 0 {
|
if nBytes > 0 {
|
||||||
common.Must(b.WriteByte(firstByte[0]))
|
common.Must(b.WriteByte(firstByte[0]))
|
||||||
}
|
}
|
||||||
for i := 0; i < 64; i++ {
|
b.ReadFrom(r)
|
||||||
_, err := b.ReadFrom(r)
|
return b, nil
|
||||||
if !b.IsEmpty() {
|
|
||||||
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.
|
// BufferedReader is a Reader that keeps its internal buffer.
|
||||||
|
Loading…
Reference in New Issue
Block a user