diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 8a1927a39ca..d4ebbc70a38 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -3,3 +3,5 @@ ### SDK Enhancements ### SDK Bugs +* Remove test dependency on golang.org/x/net. + * This was used for h2 support which is now transparently available in the stdlib. diff --git a/private/protocol/eventstream/eventstreamtest/setup_server.go b/private/protocol/eventstream/eventstreamtest/setup_server.go index 5140abd29b6..a3a0202faf9 100644 --- a/private/protocol/eventstream/eventstreamtest/setup_server.go +++ b/private/protocol/eventstream/eventstreamtest/setup_server.go @@ -8,9 +8,6 @@ import ( "net/http/httptest" ) -// /x/net/http2 is only available for the latest two versions of Go. Any Go -// version older than that cannot use the utility to configure the http2 -// server. func setupServer(server *httptest.Server, useH2 bool) *http.Client { server.Start() diff --git a/private/protocol/eventstream/eventstreamtest/setup_server_1_10.go b/private/protocol/eventstream/eventstreamtest/setup_server_1_10.go deleted file mode 100644 index 642c8235aa3..00000000000 --- a/private/protocol/eventstream/eventstreamtest/setup_server_1_10.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.15 -// +build go1.15 - -package eventstreamtest - -import ( - "crypto/tls" - "net/http" - "net/http/httptest" - - "golang.org/x/net/http2" -) - -// /x/net/http2 is only available for the latest two versions of Go. Any Go -// version older than that cannot use the utility to configure the http2 -// server. -func setupServer(server *httptest.Server, useH2 bool) *http.Client { - server.Config.TLSConfig = &tls.Config{ - InsecureSkipVerify: true, - } - - clientTrans := &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - } - - if useH2 { - http2.ConfigureServer(server.Config, nil) - http2.ConfigureTransport(clientTrans) - server.Config.TLSConfig.NextProtos = []string{http2.NextProtoTLS} - clientTrans.TLSClientConfig.NextProtos = []string{http2.NextProtoTLS} - } - server.TLS = server.Config.TLSConfig - - server.StartTLS() - - return &http.Client{ - Transport: clientTrans, - } -} diff --git a/private/protocol/eventstream/eventstreamtest/testing.go b/private/protocol/eventstream/eventstreamtest/testing.go index 3f77d9d9f91..3d9feb63476 100644 --- a/private/protocol/eventstream/eventstreamtest/testing.go +++ b/private/protocol/eventstream/eventstreamtest/testing.go @@ -21,12 +21,16 @@ import ( "github.com/aws/aws-sdk-go/awstesting/unit" "github.com/aws/aws-sdk-go/private/protocol" "github.com/aws/aws-sdk-go/private/protocol/eventstream" - "golang.org/x/net/http2" ) const ( errClientDisconnected = "client disconnected" errStreamClosed = "http2: stream closed" + + // x/net had an exported StreamError type that we could assert against, + // net/http's h2 implementation internalizes all of its error types but the + // Error() text pattern remains identical + http2StreamError = "stream error: stream ID" ) // ServeEventStream provides serving EventStream messages from a HTTP server to @@ -106,12 +110,7 @@ func (s *ServeEventStream) serveBiDirectionalStream(w http.ResponseWriter, r *ht } func isError(err error) bool { - switch err.(type) { - case http2.StreamError: - return false - } - - for _, s := range []string{errClientDisconnected, errStreamClosed} { + for _, s := range []string{errClientDisconnected, errStreamClosed, http2StreamError} { if strings.Contains(err.Error(), s) { return false } diff --git a/service/kinesis/cust_integ_shared_test.go b/service/kinesis/cust_integ_shared_test.go index a408ef4c4ba..eab7baa92d4 100644 --- a/service/kinesis/cust_integ_shared_test.go +++ b/service/kinesis/cust_integ_shared_test.go @@ -19,7 +19,6 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/awstesting/integration" "github.com/aws/aws-sdk-go/service/kinesis" - "golang.org/x/net/http2" ) var ( @@ -131,26 +130,18 @@ func TestMain(m *testing.M) { } func createClient() *kinesis.Kinesis { - ts := &http.Transport{} - - if skipTLSVerify { - ts.TLSClientConfig = &tls.Config{ - InsecureSkipVerify: true, - } + ts := &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: skipTLSVerify, + }, } - http2.ConfigureTransport(ts) switch hUsage { - case "default": - // Restore H2 optional support since the Transport/TLSConfig was - // modified. - http2.ConfigureTransport(ts) - case "1": - // Do nothing. Without usign ConfigureTransport h2 won't be available. + case "1", "default": ts.TLSClientConfig.NextProtos = []string{"http/1.1"} case "2": // Force the TLS ALPN (NextProto) to H2 only. - ts.TLSClientConfig.NextProtos = []string{http2.NextProtoTLS} + ts.TLSClientConfig.NextProtos = []string{"h2"} default: panic("unknown h usage, " + hUsage) }