浏览代码

Fix websocket client initialize

世界 1 年之前
父节点
当前提交
a0cab4f563
共有 1 个文件被更改,包括 4 次插入9 次删除
  1. 4 9
      transport/v2raywebsocket/client.go

+ 4 - 9
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, "/") {
 	if !strings.HasPrefix(requestURL.Path, "/") {
 		requestURL.Path = "/" + 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") == "" {
 	if headers.Get("User-Agent") == "" {
 		headers.Set("User-Agent", "Go-http-client/1.1")
 		headers.Set("User-Agent", "Go-http-client/1.1")