Skip to content

Commit

Permalink
drop x/net test dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws committed Jun 14, 2024
1 parent 9df4328 commit 494f482
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 66 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 0 additions & 3 deletions private/protocol/eventstream/eventstreamtest/setup_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
41 changes: 0 additions & 41 deletions private/protocol/eventstream/eventstreamtest/setup_server_1_10.go

This file was deleted.

13 changes: 6 additions & 7 deletions private/protocol/eventstream/eventstreamtest/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
21 changes: 6 additions & 15 deletions service/kinesis/cust_integ_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 494f482

Please sign in to comment.