forked from mirror/websocket
moving the new error check into existing http response error block to reduce the possibility of false positives
This commit is contained in:
parent
b67992cf90
commit
fc45505c46
23
client.go
23
client.go
|
@ -186,18 +186,6 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
|
|||
return nil, nil, errMalformedURL
|
||||
}
|
||||
|
||||
if d.TLSClientConfig != nil {
|
||||
for _, proto := range d.TLSClientConfig.NextProtos {
|
||||
if proto != "http/1.1" {
|
||||
return nil, nil, fmt.Errorf(
|
||||
"websocket: protocol %q was given but is not supported; "+
|
||||
"sharing tls.Config with net/http Transport can cause this error",
|
||||
proto,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
req := &http.Request{
|
||||
Method: http.MethodGet,
|
||||
URL: u,
|
||||
|
@ -383,6 +371,17 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
|
|||
|
||||
resp, err := http.ReadResponse(conn.br, req)
|
||||
if err != nil {
|
||||
if d.TLSClientConfig != nil {
|
||||
for _, proto := range d.TLSClientConfig.NextProtos {
|
||||
if proto != "http/1.1" {
|
||||
return nil, nil, fmt.Errorf(
|
||||
"websocket: protocol %q was given but is not supported; "+
|
||||
"sharing tls.Config with net/http Transport can cause this error",
|
||||
proto,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue