mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 18:11:28 +00:00
Fix http response check
Co-authored-by: armv9 <48624112+arm64v8a@users.noreply.github.com>
This commit is contained in:
parent
bbdd495ed5
commit
df0eef770e
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/sagernet/sing-box/common/tls"
|
"github.com/sagernet/sing-box/common/tls"
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
"github.com/sagernet/sing-box/transport/v2rayhttp"
|
"github.com/sagernet/sing-box/transport/v2rayhttp"
|
||||||
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
M "github.com/sagernet/sing/common/metadata"
|
M "github.com/sagernet/sing/common/metadata"
|
||||||
N "github.com/sagernet/sing/common/network"
|
N "github.com/sagernet/sing/common/network"
|
||||||
|
|
||||||
|
@ -92,10 +93,13 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
|
||||||
conn := newLateGunConn(pipeInWriter)
|
conn := newLateGunConn(pipeInWriter)
|
||||||
go func() {
|
go func() {
|
||||||
response, err := c.transport.RoundTrip(request)
|
response, err := c.transport.RoundTrip(request)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
conn.setup(response.Body, nil)
|
|
||||||
} else {
|
|
||||||
conn.setup(nil, err)
|
conn.setup(nil, err)
|
||||||
|
} else if response.StatusCode != 200 {
|
||||||
|
response.Body.Close()
|
||||||
|
conn.setup(nil, E.New("unexpected status: ", response.StatusCode, " ", response.Status))
|
||||||
|
} else {
|
||||||
|
conn.setup(response.Body, nil)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return conn, nil
|
return conn, nil
|
||||||
|
|
|
@ -145,6 +145,7 @@ func (c *Client) dialHTTP2(ctx context.Context) (net.Conn, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.setup(nil, err)
|
conn.setup(nil, err)
|
||||||
} else if response.StatusCode != 200 {
|
} else if response.StatusCode != 200 {
|
||||||
|
response.Body.Close()
|
||||||
conn.setup(nil, E.New("unexpected status: ", response.StatusCode, " ", response.Status))
|
conn.setup(nil, E.New("unexpected status: ", response.StatusCode, " ", response.Status))
|
||||||
} else {
|
} else {
|
||||||
conn.setup(response.Body, nil)
|
conn.setup(response.Body, nil)
|
||||||
|
|
Loading…
Reference in a new issue