better error handling in vmess inbound

pull/362/head
Darien Raymond 8 years ago
parent 43cc81e5a8
commit 13e4506781
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -147,20 +147,26 @@ func transferResponse(session *encoding.ServerSession, request *protocol.Request
bodyWriter := session.EncodeResponseBody(request, output)
// Optimize for small response packet
if data, err := input.Read(); err == nil {
if err := bodyWriter.Write(data); err != nil {
return err
}
data, err := input.Read()
if err != nil {
return err
}
if bufferedWriter, ok := output.(*bufio.BufferedWriter); ok {
bufferedWriter.SetBuffered(false)
}
if err := bodyWriter.Write(data); err != nil {
return err
}
data.Release()
if err := buf.PipeUntilEOF(input, bodyWriter); err != nil {
if bufferedWriter, ok := output.(*bufio.BufferedWriter); ok {
if err := bufferedWriter.SetBuffered(false); err != nil {
return err
}
}
if err := buf.PipeUntilEOF(input, bodyWriter); err != nil {
return err
}
if request.Option.Has(protocol.RequestOptionChunkStream) {
if err := bodyWriter.Write(buf.NewLocal(8)); err != nil {
return err

Loading…
Cancel
Save