mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-16 12:22:21 +08:00
Suppress expected error
This commit is contained in:
parent
350729cde8
commit
a940703ae1
|
@ -603,5 +603,8 @@ func wrapHttpError(err error) error {
|
|||
if strings.Contains(err.Error(), "body closed by handler") {
|
||||
return net.ErrClosed
|
||||
}
|
||||
if strings.Contains(err.Error(), "canceled with error code 268") {
|
||||
return io.EOF
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -102,5 +102,8 @@ func wrapError(err error) error {
|
|||
if strings.Contains(err.Error(), "EOF") {
|
||||
return io.EOF
|
||||
}
|
||||
if strings.Contains(err.Error(), "the client connection is closing") {
|
||||
return net.ErrClosed
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/sagernet/sing/common"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
type HTTPConn struct {
|
||||
|
@ -16,11 +17,13 @@ type HTTPConn struct {
|
|||
}
|
||||
|
||||
func (c *HTTPConn) Read(b []byte) (n int, err error) {
|
||||
return c.reader.Read(b)
|
||||
n, err = c.reader.Read(b)
|
||||
return n, wrapError(err)
|
||||
}
|
||||
|
||||
func (c *HTTPConn) Write(b []byte) (n int, err error) {
|
||||
return c.writer.Write(b)
|
||||
n, err = c.writer.Write(b)
|
||||
return n, wrapError(err)
|
||||
}
|
||||
|
||||
func (c *HTTPConn) Close() error {
|
||||
|
@ -59,3 +62,10 @@ func (c *ServerHTTPConn) Write(b []byte) (n int, err error) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func wrapError(err error) error {
|
||||
if E.IsMulti(err, io.ErrUnexpectedEOF) {
|
||||
return io.EOF
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user