|
@@ -197,11 +197,18 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
|
|
req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")}
|
|
req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")}
|
|
|
}
|
|
}
|
|
|
for k, vs := range requestHeader {
|
|
for k, vs := range requestHeader {
|
|
|
- if k == "Host" {
|
|
|
|
|
|
|
+ switch {
|
|
|
|
|
+ case k == "Host":
|
|
|
if len(vs) > 0 {
|
|
if len(vs) > 0 {
|
|
|
req.Host = vs[0]
|
|
req.Host = vs[0]
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
|
|
+ case k == "Upgrade" ||
|
|
|
|
|
+ k == "Connection" ||
|
|
|
|
|
+ k == "Sec-Websocket-Key" ||
|
|
|
|
|
+ k == "Sec-Websocket-Version" ||
|
|
|
|
|
+ (k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
|
|
|
|
|
+ return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
|
|
|
|
|
+ default:
|
|
|
req.Header[k] = vs
|
|
req.Header[k] = vs
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|