proxy: enable http2 for connecting to members

enable http2 when transport specified a custom TLS config, which was
not automatically enable.

Issue 5033
This commit is contained in:
朱鹏
2016-04-14 12:10:10 +08:00
parent 6c1cc1d4ea
commit 67db28f979

View File

@@ -19,6 +19,8 @@ import (
"net/http"
"strings"
"time"
"golang.org/x/net/http2"
)
const (
@@ -42,6 +44,14 @@ type GetProxyURLs func() []string
// which will proxy requests to an etcd cluster.
// The handler will periodically update its view of the cluster.
func NewHandler(t *http.Transport, urlsFunc GetProxyURLs, failureWait time.Duration, refreshInterval time.Duration) http.Handler {
if t.TLSClientConfig != nil {
// Enable http2, see Issue 5033.
err := http2.ConfigureTransport(t)
if err != nil {
plog.Infof("Error enabling Transport HTTP/2 support: %v", err)
}
}
p := &reverseProxy{
director: newDirector(urlsFunc, failureWait, refreshInterval),
transport: t,