diff --git a/client.go b/client.go index a910356..c5c3db0 100644 --- a/client.go +++ b/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 }