From 2cba614e8ff920c60240d2677bc019af32ee04e5 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 21 Oct 2015 11:20:37 -0600 Subject: [PATCH] http2: remove Transport.Fallback We decided to glue together the HTTP/1 and HTTP/2 Transports in the other direction, having the HTTP/1 code (net/http.Transport) start the flow. Remove the http2 Transport.Fallback for now, rather than leaving it half implemented. For background, see https://golang.org/cl/16090 Updates golang/go#6891 Change-Id: I511bc6d35a1a9a8e20010bd95ff694a894f42aa4 Reviewed-on: https://go-review.googlesource.com/16181 Reviewed-by: Andrew Gerrand --- http2/transport.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/http2/transport.go b/http2/transport.go index 66df78e4..2c5e7acd 100644 --- a/http2/transport.go +++ b/http2/transport.go @@ -21,9 +21,8 @@ import ( "golang.org/x/net/http2/hpack" ) +// Transport is an HTTP/2 Transport. type Transport struct { - Fallback http.RoundTripper - // TODO: remove this and make more general with a TLS dial hook, like http InsecureTLSDial bool @@ -82,10 +81,7 @@ func (sew stickyErrWriter) Write(p []byte) (n int, err error) { func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { if req.URL.Scheme != "https" { - if t.Fallback == nil { - return nil, errors.New("http2: unsupported scheme and no Fallback") - } - return t.Fallback.RoundTrip(req) + return nil, errors.New("http2: unsupported scheme") } host, port, err := net.SplitHostPort(req.URL.Host) @@ -235,11 +231,10 @@ func (t *Transport) newClientConn(host, key string, tconn *tls.Conn) (*clientCon } state := tconn.ConnectionState() if p := state.NegotiatedProtocol; p != NextProtoTLS { - // TODO(bradfitz): fall back to Fallback - return nil, fmt.Errorf("bad protocol: %v", p) + return nil, fmt.Errorf("http2: unexpected ALPN protocol %q; want %q", p, NextProtoTLS) } if !state.NegotiatedProtocolIsMutual { - return nil, errors.New("could not negotiate protocol mutually") + return nil, errors.New("http2: could not negotiate protocol mutually") } if _, err := tconn.Write(clientPreface); err != nil { return nil, err