mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-16 06:52:21 +08:00
Fix websocket client initialize
This commit is contained in:
parent
aeb7308e81
commit
a0cab4f563
|
@ -55,15 +55,10 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
|
||||||
if !strings.HasPrefix(requestURL.Path, "/") {
|
if !strings.HasPrefix(requestURL.Path, "/") {
|
||||||
requestURL.Path = "/" + requestURL.Path
|
requestURL.Path = "/" + requestURL.Path
|
||||||
}
|
}
|
||||||
headers := make(http.Header)
|
headers := options.Headers.Build()
|
||||||
for key, value := range options.Headers {
|
if host := headers.Get("Host"); host != "" {
|
||||||
headers[key] = value
|
headers.Del("Host")
|
||||||
if key == "Host" {
|
requestURL.Host = host
|
||||||
if len(value) > 1 {
|
|
||||||
return nil, E.New("multiple Host headers")
|
|
||||||
}
|
|
||||||
requestURL.Host = value[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if headers.Get("User-Agent") == "" {
|
if headers.Get("User-Agent") == "" {
|
||||||
headers.Set("User-Agent", "Go-http-client/1.1")
|
headers.Set("User-Agent", "Go-http-client/1.1")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user