mirror of https://github.com/gorilla/websocket.git
Compare commits
2 Commits
71e79a20b9
...
7785671495
Author | SHA1 | Date |
---|---|---|
好为 | 7785671495 | |
willard | 873ca6009f |
10
client.go
10
client.go
|
@ -187,6 +187,10 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
|
|||
return nil, nil, errMalformedURL
|
||||
}
|
||||
|
||||
host := requestHeader.Get("Host")
|
||||
if host == "" {
|
||||
host = u.Host
|
||||
}
|
||||
req := &http.Request{
|
||||
Method: http.MethodGet,
|
||||
URL: u,
|
||||
|
@ -194,7 +198,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
|
|||
ProtoMajor: 1,
|
||||
ProtoMinor: 1,
|
||||
Header: make(http.Header),
|
||||
Host: u.Host,
|
||||
Host: host,
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
|
@ -340,8 +344,12 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
|
|||
|
||||
cfg := cloneTLSConfig(d.TLSClientConfig)
|
||||
if cfg.ServerName == "" {
|
||||
if host != "" {
|
||||
cfg.ServerName = host
|
||||
} else {
|
||||
cfg.ServerName = hostNoPort
|
||||
}
|
||||
}
|
||||
tlsConn := tls.Client(netConn, cfg)
|
||||
netConn = tlsConn
|
||||
|
||||
|
|
Loading…
Reference in New Issue