From 67db28f979748bad10e6d9939c551e8a2f2677ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E9=B9=8F?= Date: Thu, 14 Apr 2016 12:10:10 +0800 Subject: [PATCH] proxy: enable http2 for connecting to members enable http2 when transport specified a custom TLS config, which was not automatically enable. Issue 5033 --- proxy/httpproxy/proxy.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/proxy/httpproxy/proxy.go b/proxy/httpproxy/proxy.go index e70d47487..35b8e51e7 100644 --- a/proxy/httpproxy/proxy.go +++ b/proxy/httpproxy/proxy.go @@ -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,