return an error when Dialer.TLSClientConfig.NextProtos contains a protocol that is not http/1.1

This commit is contained in:
Chan Kang 2022-06-12 00:08:04 -04:00
parent 27d91a9be5
commit 8a0b8d46a3
1 changed files with 7 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
@ -185,6 +186,12 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
return nil, nil, errMalformedURL
}
for _, proto := range d.TLSClientConfig.NextProtos {
if proto != "http/1.1" {
return nil, nil, fmt.Errorf("protocol %q is currently not supported", proto)
}
}
req := &http.Request{
Method: http.MethodGet,
URL: u,