Fix parsing query in http path

This commit is contained in:
世界
2023-04-12 15:14:55 +08:00
parent 84bd997742
commit 62bcf22c26
9 changed files with 43 additions and 17 deletions

View File

@@ -5,7 +5,6 @@ import (
"net"
"net/http"
"net/url"
"strings"
"time"
"github.com/sagernet/sing-box/adapter"
@@ -15,6 +14,7 @@ import (
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
sHTTP "github.com/sagernet/sing/protocol/http"
"github.com/sagernet/websocket"
)
@@ -58,12 +58,9 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
}
uri.Host = serverAddr.String()
uri.Path = options.Path
if !strings.HasPrefix(uri.Path, "/") {
uri.Path = "/" + uri.Path
}
if strings.HasSuffix(uri.Path, "?") {
uri.ForceQuery = true
uri.Path = strings.TrimSuffix(uri.Path, "?")
err := sHTTP.URLSetPath(&uri, options.Path)
if err != nil {
return nil
}
headers := make(http.Header)
for key, value := range options.Headers {