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 <adg@golang.org>
This commit is contained in:
Brad Fitzpatrick
2015-10-21 11:20:37 -06:00
parent e71042db1c
commit 2cba614e8f

View File

@@ -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