1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-26 23:49:08 -04:00

more test cases

This commit is contained in:
Darien Raymond
2018-10-24 13:51:04 +02:00
parent 2621305413
commit de4072a65a
2 changed files with 25 additions and 14 deletions

View File

@@ -98,27 +98,17 @@ func (r *BufferedReader) ReadAtMost(size int32) (MultiBuffer, error) {
func (r *BufferedReader) writeToInternal(writer io.Writer) (int64, error) {
mbWriter := NewWriter(writer)
totalBytes := int64(0)
var sc SizeCounter
if r.Buffer != nil {
totalBytes += int64(r.Buffer.Len())
sc.Size = int64(r.Buffer.Len())
if err := mbWriter.WriteMultiBuffer(r.Buffer); err != nil {
return 0, err
}
r.Buffer = nil
}
for {
mb, err := r.Reader.ReadMultiBuffer()
if mb != nil {
totalBytes += int64(mb.Len())
if werr := mbWriter.WriteMultiBuffer(mb); werr != nil {
return totalBytes, err
}
}
if err != nil {
return totalBytes, err
}
}
err := Copy(r.Reader, mbWriter, CountSize(&sc))
return sc.Size, err
}
// WriteTo implements io.WriterTo.