From a0cab4f5639d22679633ace11ba259bc9123a38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 22 Dec 2023 20:37:49 +0800 Subject: [PATCH] Fix websocket client initialize --- transport/v2raywebsocket/client.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/transport/v2raywebsocket/client.go b/transport/v2raywebsocket/client.go index 7fda40cc..5de610c2 100644 --- a/transport/v2raywebsocket/client.go +++ b/transport/v2raywebsocket/client.go @@ -55,15 +55,10 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt if !strings.HasPrefix(requestURL.Path, "/") { requestURL.Path = "/" + requestURL.Path } - headers := make(http.Header) - for key, value := range options.Headers { - headers[key] = value - if key == "Host" { - if len(value) > 1 { - return nil, E.New("multiple Host headers") - } - requestURL.Host = value[0] - } + headers := options.Headers.Build() + if host := headers.Get("Host"); host != "" { + headers.Del("Host") + requestURL.Host = host } if headers.Get("User-Agent") == "" { headers.Set("User-Agent", "Go-http-client/1.1")