mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
skip empty payload in ray
This commit is contained in:
parent
38e4cad8d1
commit
f7379bc1c3
@ -70,6 +70,10 @@ func (v *Stream) Read() (*buf.Buffer, error) {
|
||||
}
|
||||
|
||||
func (v *Stream) Write(data *buf.Buffer) (err error) {
|
||||
if data.IsEmpty() {
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-v.destClose:
|
||||
return io.ErrClosedPipe
|
||||
|
@ -13,7 +13,9 @@ func TestStreamIO(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
stream := NewStream()
|
||||
assert.Error(stream.Write(buf.New())).IsNil()
|
||||
b1 := buf.New()
|
||||
b1.AppendBytes('a')
|
||||
assert.Error(stream.Write(b1)).IsNil()
|
||||
|
||||
_, err := stream.Read()
|
||||
assert.Error(err).IsNil()
|
||||
@ -22,7 +24,9 @@ func TestStreamIO(t *testing.T) {
|
||||
_, err = stream.Read()
|
||||
assert.Error(err).Equals(io.EOF)
|
||||
|
||||
err = stream.Write(buf.New())
|
||||
b2 := buf.New()
|
||||
b2.AppendBytes('b')
|
||||
err = stream.Write(b2)
|
||||
assert.Error(err).Equals(io.ErrClosedPipe)
|
||||
}
|
||||
|
||||
@ -30,7 +34,9 @@ func TestStreamClose(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
stream := NewStream()
|
||||
assert.Error(stream.Write(buf.New())).IsNil()
|
||||
b1 := buf.New()
|
||||
b1.AppendBytes('a')
|
||||
assert.Error(stream.Write(b1)).IsNil()
|
||||
|
||||
stream.Close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user