|
|
@ -2,10 +2,12 @@ package io
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
|
|
|
|
"v2ray.com/core/common/errors"
|
|
|
|
"v2ray.com/core/common/errors"
|
|
|
|
"v2ray.com/core/common/log"
|
|
|
|
"v2ray.com/core/common/log"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Pipe dumps all content from reader to writer, until an error happens.
|
|
|
|
func Pipe(reader Reader, writer Writer) error {
|
|
|
|
func Pipe(reader Reader, writer Writer) error {
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
buffer, err := reader.Read()
|
|
|
|
buffer, err := reader.Read()
|
|
|
@ -28,6 +30,7 @@ func Pipe(reader Reader, writer Writer) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PipeUntilEOF behaves the same as Pipe(). The only difference is PipeUntilEOF returns nil on EOF.
|
|
|
|
func PipeUntilEOF(reader Reader, writer Writer) error {
|
|
|
|
func PipeUntilEOF(reader Reader, writer Writer) error {
|
|
|
|
err := Pipe(reader, writer)
|
|
|
|
err := Pipe(reader, writer)
|
|
|
|
if err != nil && errors.Cause(err) != io.EOF {
|
|
|
|
if err != nil && errors.Cause(err) != io.EOF {
|
|
|
|