1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-07 02:38:10 -05:00
v2fly/common/io/transport.go

17 lines
229 B
Go
Raw Normal View History

2016-01-29 08:39:55 -05:00
package io
2016-04-18 12:44:10 -04:00
func Pipe(reader Reader, writer Writer) error {
2016-01-29 08:39:55 -05:00
for {
buffer, err := reader.Read()
2016-02-01 06:22:29 -05:00
if buffer.Len() > 0 {
2016-04-18 12:44:10 -04:00
err = writer.Write(buffer)
2016-01-29 08:39:55 -05:00
} else {
2016-02-01 06:22:29 -05:00
buffer.Release()
2016-01-29 08:39:55 -05:00
}
if err != nil {
2016-04-18 12:44:10 -04:00
return nil
2016-01-29 08:39:55 -05:00
}
}
}