http2: remove ancient build-tagged files for unsupported Go versions

x/net requires Go 1.18. No need to keep untested Go 1.11, Go 1.15, etc
support around.

Change-Id: I3588d273b543dec9ca120894ab36255f845abc20
Reviewed-on: https://go-review.googlesource.com/c/net/+/540236
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Christopher Taylor <ccmtaylor@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/http2/go111.go b/http2/go111.go
deleted file mode 100644
index 4ced74a..0000000
--- a/http2/go111.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build go1.11
-
-package http2
-
-import (
-	"net/http/httptrace"
-	"net/textproto"
-)
-
-func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool {
-	return trace != nil && trace.WroteHeaderField != nil
-}
-
-func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) {
-	if trace != nil && trace.WroteHeaderField != nil {
-		trace.WroteHeaderField(k, []string{v})
-	}
-}
-
-func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error {
-	if trace != nil {
-		return trace.Got1xxResponse
-	}
-	return nil
-}
diff --git a/http2/go115.go b/http2/go115.go
deleted file mode 100644
index 13a2d92..0000000
--- a/http2/go115.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build go1.15
-
-package http2
-
-import (
-	"context"
-	"crypto/tls"
-)
-
-// dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS
-// connection.
-func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
-	dialer := &tls.Dialer{
-		Config: cfg,
-	}
-	cn, err := dialer.DialContext(ctx, network, addr)
-	if err != nil {
-		return nil, err
-	}
-	tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed
-	return tlsCn, nil
-}
diff --git a/http2/go118.go b/http2/go118.go
deleted file mode 100644
index a445ae1..0000000
--- a/http2/go118.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build go1.18
-
-package http2
-
-import (
-	"crypto/tls"
-	"net"
-)
-
-func tlsUnderlyingConn(tc *tls.Conn) net.Conn {
-	return tc.NetConn()
-}
diff --git a/http2/not_go111.go b/http2/not_go111.go
deleted file mode 100644
index f4d63f4..0000000
--- a/http2/not_go111.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !go1.11
-
-package http2
-
-import (
-	"net/http/httptrace"
-	"net/textproto"
-)
-
-func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { return false }
-
-func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) {}
-
-func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error {
-	return nil
-}
diff --git a/http2/not_go115.go b/http2/not_go115.go
deleted file mode 100644
index 6357534..0000000
--- a/http2/not_go115.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !go1.15
-
-package http2
-
-import (
-	"context"
-	"crypto/tls"
-)
-
-// dialTLSWithContext opens a TLS connection.
-func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
-	cn, err := tls.Dial(network, addr, cfg)
-	if err != nil {
-		return nil, err
-	}
-	if err := cn.Handshake(); err != nil {
-		return nil, err
-	}
-	if cfg.InsecureSkipVerify {
-		return cn, nil
-	}
-	if err := cn.VerifyHostname(cfg.ServerName); err != nil {
-		return nil, err
-	}
-	return cn, nil
-}
diff --git a/http2/not_go118.go b/http2/not_go118.go
deleted file mode 100644
index b1b11c0..0000000
--- a/http2/not_go118.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !go1.18
-
-package http2
-
-import (
-	"crypto/tls"
-	"net"
-)
-
-func tlsUnderlyingConn(tc *tls.Conn) net.Conn {
-	return nil
-}
diff --git a/http2/transport.go b/http2/transport.go
index 4515b22..df578b8 100644
--- a/http2/transport.go
+++ b/http2/transport.go
@@ -1018,7 +1018,7 @@
 	if !ok {
 		return
 	}
-	if nc := tlsUnderlyingConn(tc); nc != nil {
+	if nc := tc.NetConn(); nc != nil {
 		nc.Close()
 	}
 }
@@ -3201,3 +3201,34 @@
 		trace.GotFirstResponseByte()
 	}
 }
+
+func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool {
+	return trace != nil && trace.WroteHeaderField != nil
+}
+
+func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) {
+	if trace != nil && trace.WroteHeaderField != nil {
+		trace.WroteHeaderField(k, []string{v})
+	}
+}
+
+func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error {
+	if trace != nil {
+		return trace.Got1xxResponse
+	}
+	return nil
+}
+
+// dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS
+// connection.
+func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
+	dialer := &tls.Dialer{
+		Config: cfg,
+	}
+	cn, err := dialer.DialContext(ctx, network, addr)
+	if err != nil {
+		return nil, err
+	}
+	tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed
+	return tlsCn, nil
+}
diff --git a/http2/transport_go117_test.go b/http2/transport_go117_test.go
deleted file mode 100644
index 0f257ad..0000000
--- a/http2/transport_go117_test.go
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build go1.17
-
-package http2
-
-import (
-	"context"
-	"crypto/tls"
-	"errors"
-	"net/http"
-	"net/http/httptest"
-
-	"testing"
-)
-
-func TestTransportDialTLSContext(t *testing.T) {
-	blockCh := make(chan struct{})
-	serverTLSConfigFunc := func(ts *httptest.Server) {
-		ts.Config.TLSConfig = &tls.Config{
-			// Triggers the server to request the clients certificate
-			// during TLS handshake.
-			ClientAuth: tls.RequestClientCert,
-		}
-	}
-	ts := newServerTester(t,
-		func(w http.ResponseWriter, r *http.Request) {},
-		optOnlyServer,
-		serverTLSConfigFunc,
-	)
-	defer ts.Close()
-	tr := &Transport{
-		TLSClientConfig: &tls.Config{
-			GetClientCertificate: func(cri *tls.CertificateRequestInfo) (*tls.Certificate, error) {
-				// Tests that the context provided to `req` is
-				// passed into this function.
-				close(blockCh)
-				<-cri.Context().Done()
-				return nil, cri.Context().Err()
-			},
-			InsecureSkipVerify: true,
-		},
-	}
-	defer tr.CloseIdleConnections()
-	req, err := http.NewRequest(http.MethodGet, ts.ts.URL, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
-	req = req.WithContext(ctx)
-	errCh := make(chan error)
-	go func() {
-		defer close(errCh)
-		res, err := tr.RoundTrip(req)
-		if err != nil {
-			errCh <- err
-			return
-		}
-		res.Body.Close()
-	}()
-	// Wait for GetClientCertificate handler to be called
-	<-blockCh
-	// Cancel the context
-	cancel()
-	// Expect the cancellation error here
-	err = <-errCh
-	if err == nil {
-		t.Fatal("cancelling context during client certificate fetch did not error as expected")
-		return
-	}
-	if !errors.Is(err, context.Canceled) {
-		t.Fatalf("unexpected error returned after cancellation: %v", err)
-	}
-}
-
-// TestDialRaceResumesDial tests that, given two concurrent requests
-// to the same address, when the first Dial is interrupted because
-// the first request's context is cancelled, the second request
-// resumes the dial automatically.
-func TestDialRaceResumesDial(t *testing.T) {
-	blockCh := make(chan struct{})
-	serverTLSConfigFunc := func(ts *httptest.Server) {
-		ts.Config.TLSConfig = &tls.Config{
-			// Triggers the server to request the clients certificate
-			// during TLS handshake.
-			ClientAuth: tls.RequestClientCert,
-		}
-	}
-	ts := newServerTester(t,
-		func(w http.ResponseWriter, r *http.Request) {},
-		optOnlyServer,
-		serverTLSConfigFunc,
-	)
-	defer ts.Close()
-	tr := &Transport{
-		TLSClientConfig: &tls.Config{
-			GetClientCertificate: func(cri *tls.CertificateRequestInfo) (*tls.Certificate, error) {
-				select {
-				case <-blockCh:
-					// If we already errored, return without error.
-					return &tls.Certificate{}, nil
-				default:
-				}
-				close(blockCh)
-				<-cri.Context().Done()
-				return nil, cri.Context().Err()
-			},
-			InsecureSkipVerify: true,
-		},
-	}
-	defer tr.CloseIdleConnections()
-	req, err := http.NewRequest(http.MethodGet, ts.ts.URL, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	// Create two requests with independent cancellation.
-	ctx1, cancel1 := context.WithCancel(context.Background())
-	defer cancel1()
-	req1 := req.WithContext(ctx1)
-	ctx2, cancel2 := context.WithCancel(context.Background())
-	defer cancel2()
-	req2 := req.WithContext(ctx2)
-	errCh := make(chan error)
-	go func() {
-		res, err := tr.RoundTrip(req1)
-		if err != nil {
-			errCh <- err
-			return
-		}
-		res.Body.Close()
-	}()
-	successCh := make(chan struct{})
-	go func() {
-		// Don't start request until first request
-		// has initiated the handshake.
-		<-blockCh
-		res, err := tr.RoundTrip(req2)
-		if err != nil {
-			errCh <- err
-			return
-		}
-		res.Body.Close()
-		// Close successCh to indicate that the second request
-		// made it to the server successfully.
-		close(successCh)
-	}()
-	// Wait for GetClientCertificate handler to be called
-	<-blockCh
-	// Cancel the context first
-	cancel1()
-	// Expect the cancellation error here
-	err = <-errCh
-	if err == nil {
-		t.Fatal("cancelling context during client certificate fetch did not error as expected")
-		return
-	}
-	if !errors.Is(err, context.Canceled) {
-		t.Fatalf("unexpected error returned after cancellation: %v", err)
-	}
-	select {
-	case err := <-errCh:
-		t.Fatalf("unexpected second error: %v", err)
-	case <-successCh:
-	}
-}
diff --git a/http2/transport_test.go b/http2/transport_test.go
index 9984848..a81131f 100644
--- a/http2/transport_test.go
+++ b/http2/transport_test.go
@@ -6369,3 +6369,154 @@
 	}
 	res.Body.Close()
 }
+
+func TestTransportDialTLSContext(t *testing.T) {
+	blockCh := make(chan struct{})
+	serverTLSConfigFunc := func(ts *httptest.Server) {
+		ts.Config.TLSConfig = &tls.Config{
+			// Triggers the server to request the clients certificate
+			// during TLS handshake.
+			ClientAuth: tls.RequestClientCert,
+		}
+	}
+	ts := newServerTester(t,
+		func(w http.ResponseWriter, r *http.Request) {},
+		optOnlyServer,
+		serverTLSConfigFunc,
+	)
+	defer ts.Close()
+	tr := &Transport{
+		TLSClientConfig: &tls.Config{
+			GetClientCertificate: func(cri *tls.CertificateRequestInfo) (*tls.Certificate, error) {
+				// Tests that the context provided to `req` is
+				// passed into this function.
+				close(blockCh)
+				<-cri.Context().Done()
+				return nil, cri.Context().Err()
+			},
+			InsecureSkipVerify: true,
+		},
+	}
+	defer tr.CloseIdleConnections()
+	req, err := http.NewRequest(http.MethodGet, ts.ts.URL, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+	ctx, cancel := context.WithCancel(context.Background())
+	defer cancel()
+	req = req.WithContext(ctx)
+	errCh := make(chan error)
+	go func() {
+		defer close(errCh)
+		res, err := tr.RoundTrip(req)
+		if err != nil {
+			errCh <- err
+			return
+		}
+		res.Body.Close()
+	}()
+	// Wait for GetClientCertificate handler to be called
+	<-blockCh
+	// Cancel the context
+	cancel()
+	// Expect the cancellation error here
+	err = <-errCh
+	if err == nil {
+		t.Fatal("cancelling context during client certificate fetch did not error as expected")
+		return
+	}
+	if !errors.Is(err, context.Canceled) {
+		t.Fatalf("unexpected error returned after cancellation: %v", err)
+	}
+}
+
+// TestDialRaceResumesDial tests that, given two concurrent requests
+// to the same address, when the first Dial is interrupted because
+// the first request's context is cancelled, the second request
+// resumes the dial automatically.
+func TestDialRaceResumesDial(t *testing.T) {
+	blockCh := make(chan struct{})
+	serverTLSConfigFunc := func(ts *httptest.Server) {
+		ts.Config.TLSConfig = &tls.Config{
+			// Triggers the server to request the clients certificate
+			// during TLS handshake.
+			ClientAuth: tls.RequestClientCert,
+		}
+	}
+	ts := newServerTester(t,
+		func(w http.ResponseWriter, r *http.Request) {},
+		optOnlyServer,
+		serverTLSConfigFunc,
+	)
+	defer ts.Close()
+	tr := &Transport{
+		TLSClientConfig: &tls.Config{
+			GetClientCertificate: func(cri *tls.CertificateRequestInfo) (*tls.Certificate, error) {
+				select {
+				case <-blockCh:
+					// If we already errored, return without error.
+					return &tls.Certificate{}, nil
+				default:
+				}
+				close(blockCh)
+				<-cri.Context().Done()
+				return nil, cri.Context().Err()
+			},
+			InsecureSkipVerify: true,
+		},
+	}
+	defer tr.CloseIdleConnections()
+	req, err := http.NewRequest(http.MethodGet, ts.ts.URL, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+	// Create two requests with independent cancellation.
+	ctx1, cancel1 := context.WithCancel(context.Background())
+	defer cancel1()
+	req1 := req.WithContext(ctx1)
+	ctx2, cancel2 := context.WithCancel(context.Background())
+	defer cancel2()
+	req2 := req.WithContext(ctx2)
+	errCh := make(chan error)
+	go func() {
+		res, err := tr.RoundTrip(req1)
+		if err != nil {
+			errCh <- err
+			return
+		}
+		res.Body.Close()
+	}()
+	successCh := make(chan struct{})
+	go func() {
+		// Don't start request until first request
+		// has initiated the handshake.
+		<-blockCh
+		res, err := tr.RoundTrip(req2)
+		if err != nil {
+			errCh <- err
+			return
+		}
+		res.Body.Close()
+		// Close successCh to indicate that the second request
+		// made it to the server successfully.
+		close(successCh)
+	}()
+	// Wait for GetClientCertificate handler to be called
+	<-blockCh
+	// Cancel the context first
+	cancel1()
+	// Expect the cancellation error here
+	err = <-errCh
+	if err == nil {
+		t.Fatal("cancelling context during client certificate fetch did not error as expected")
+		return
+	}
+	if !errors.Is(err, context.Canceled) {
+		t.Fatalf("unexpected error returned after cancellation: %v", err)
+	}
+	select {
+	case err := <-errCh:
+		t.Fatalf("unexpected second error: %v", err)
+	case <-successCh:
+	}
+}