mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 08:31:30 +00: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") {
|
if strings.Contains(err.Error(), "body closed by handler") {
|
||||||
return net.ErrClosed
|
return net.ErrClosed
|
||||||
}
|
}
|
||||||
|
if strings.Contains(err.Error(), "canceled with error code 268") {
|
||||||
|
return io.EOF
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,5 +102,8 @@ func wrapError(err error) error {
|
||||||
if strings.Contains(err.Error(), "EOF") {
|
if strings.Contains(err.Error(), "EOF") {
|
||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
|
if strings.Contains(err.Error(), "the client connection is closing") {
|
||||||
|
return net.ErrClosed
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPConn struct {
|
type HTTPConn struct {
|
||||||
|
@ -16,11 +17,13 @@ type HTTPConn struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HTTPConn) Read(b []byte) (n int, err error) {
|
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) {
|
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 {
|
func (c *HTTPConn) Close() error {
|
||||||
|
@ -59,3 +62,10 @@ func (c *ServerHTTPConn) Write(b []byte) (n int, err error) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func wrapError(err error) error {
|
||||||
|
if E.IsMulti(err, io.ErrUnexpectedEOF) {
|
||||||
|
return io.EOF
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue