From 8a0b8d46a39f15ac6c5c31c5af83e39acb8067b5 Mon Sep 17 00:00:00 2001 From: Chan Kang Date: Sun, 12 Jun 2022 00:08:04 -0400 Subject: [PATCH] return an error when Dialer.TLSClientConfig.NextProtos contains a protocol that is not http/1.1 --- client.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client.go b/client.go index 2efd835..3be04aa 100644 --- a/client.go +++ b/client.go @@ -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,