mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 00:21:30 +00:00
Add name to errors from v2ray HTTP transports
This commit is contained in:
parent
8a17043502
commit
94707dfcdd
|
@ -100,7 +100,7 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
|
||||||
conn.setup(nil, err)
|
conn.setup(nil, err)
|
||||||
} else if response.StatusCode != 200 {
|
} else if response.StatusCode != 200 {
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
conn.setup(nil, E.New("unexpected status: ", response.Status))
|
conn.setup(nil, E.New("v2ray-grpc: unexpected status: ", response.Status))
|
||||||
} else {
|
} else {
|
||||||
conn.setup(response.Body, nil)
|
conn.setup(response.Body, nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ func (c *Client) dialHTTP2(ctx context.Context) (net.Conn, error) {
|
||||||
conn.Setup(nil, err)
|
conn.Setup(nil, err)
|
||||||
} else if response.StatusCode != 200 {
|
} else if response.StatusCode != 200 {
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
conn.Setup(nil, E.New("unexpected status: ", response.Status))
|
conn.Setup(nil, E.New("v2ray-http: unexpected status: ", response.Status))
|
||||||
} else {
|
} else {
|
||||||
conn.Setup(response.Body, nil)
|
conn.Setup(response.Body, nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func (c *HTTPConn) Read(b []byte) (n int, err error) {
|
||||||
return 0, E.Cause(err, "read response")
|
return 0, E.Cause(err, "read response")
|
||||||
}
|
}
|
||||||
if response.StatusCode != 200 {
|
if response.StatusCode != 200 {
|
||||||
return 0, E.New("unexpected status: ", response.Status)
|
return 0, E.New("v2ray-http: unexpected status: ", response.Status)
|
||||||
}
|
}
|
||||||
if cacheLen := reader.Buffered(); cacheLen > 0 {
|
if cacheLen := reader.Buffered(); cacheLen > 0 {
|
||||||
c.responseCache = buf.NewSize(cacheLen)
|
c.responseCache = buf.NewSize(cacheLen)
|
||||||
|
|
|
@ -104,7 +104,7 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
|
||||||
if response.StatusCode != 101 ||
|
if response.StatusCode != 101 ||
|
||||||
!strings.EqualFold(response.Header.Get("Connection"), "upgrade") ||
|
!strings.EqualFold(response.Header.Get("Connection"), "upgrade") ||
|
||||||
!strings.EqualFold(response.Header.Get("Upgrade"), "websocket") {
|
!strings.EqualFold(response.Header.Get("Upgrade"), "websocket") {
|
||||||
return nil, E.New("unexpected status: ", response.Status)
|
return nil, E.New("v2ray-http-upgrade: unexpected status: ", response.Status)
|
||||||
}
|
}
|
||||||
if bufReader.Buffered() > 0 {
|
if bufReader.Buffered() > 0 {
|
||||||
buffer := buf.NewSize(bufReader.Buffered())
|
buffer := buf.NewSize(bufReader.Buffered())
|
||||||
|
|
Loading…
Reference in a new issue