mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-10 02:53:12 +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/option"
|
||||
"github.com/sagernet/sing-box/transport/v2rayhttp"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
N "github.com/sagernet/sing/common/network"
|
||||
|
||||
|
@ -92,10 +93,13 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
|
|||
conn := newLateGunConn(pipeInWriter)
|
||||
go func() {
|
||||
response, err := c.transport.RoundTrip(request)
|
||||
if err == nil {
|
||||
conn.setup(response.Body, nil)
|
||||
} else {
|
||||
if err != nil {
|
||||
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
|
||||
|
|
|
@ -145,6 +145,7 @@ func (c *Client) dialHTTP2(ctx context.Context) (net.Conn, error) {
|
|||
if err != nil {
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue