Skip to content

Commit

Permalink
remove unneeded network from custom dial function used in HTTP/3 (qui…
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored and nmldiegues committed Jun 6, 2022
1 parent 8b6278f commit 1fd0216
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions http3/client.go
Expand Up @@ -34,7 +34,7 @@ var defaultQuicConfig = &quic.Config{
Versions: []protocol.VersionNumber{protocol.VersionTLS},
}

type dialFunc func(ctx context.Context, network, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)
type dialFunc func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)

var dialAddr = quic.DialAddrEarlyContext

Expand Down Expand Up @@ -101,7 +101,7 @@ func newClient(hostname string, tlsConf *tls.Config, opts *roundTripperOpts, con
func (c *client) dial(ctx context.Context) error {
var err error
if c.dialer != nil {
c.conn, err = c.dialer(ctx, "udp", c.hostname, c.tlsConf, c.config)
c.conn, err = c.dialer(ctx, c.hostname, c.tlsConf, c.config)
} else {
c.conn, err = dialAddr(ctx, c.hostname, c.tlsConf, c.config)
}
Expand Down
3 changes: 1 addition & 2 deletions http3/client_test.go
Expand Up @@ -121,9 +121,8 @@ var _ = Describe("Client", func() {
ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
defer cancel()
var dialerCalled bool
dialer := func(ctxP context.Context, network, address string, tlsConfP *tls.Config, quicConfP *quic.Config) (quic.EarlyConnection, error) {
dialer := func(ctxP context.Context, address string, tlsConfP *tls.Config, quicConfP *quic.Config) (quic.EarlyConnection, error) {
Expect(ctxP).To(Equal(ctx))
Expect(network).To(Equal("udp"))
Expect(address).To(Equal("localhost:1337"))
Expect(tlsConfP.ServerName).To(Equal("foo.bar"))
Expect(quicConfP.MaxIdleTimeout).To(Equal(quicConf.MaxIdleTimeout))
Expand Down
2 changes: 1 addition & 1 deletion http3/roundtrip.go
Expand Up @@ -50,7 +50,7 @@ type RoundTripper struct {
// Dial specifies an optional dial function for creating QUIC
// connections for requests.
// If Dial is nil, quic.DialAddrEarlyContext will be used.
Dial func(ctx context.Context, network, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)
Dial func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)

// MaxResponseHeaderBytes specifies a limit on how many response bytes are
// allowed in the server's response header.
Expand Down
2 changes: 1 addition & 1 deletion http3/roundtrip_test.go
Expand Up @@ -127,7 +127,7 @@ var _ = Describe("RoundTripper", func() {

It("uses the custom dialer, if provided", func() {
var dialed bool
dialer := func(_ context.Context, _, _ string, tlsCfgP *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
dialer := func(_ context.Context, _ string, tlsCfgP *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
dialed = true
return nil, errors.New("handshake error")
}
Expand Down

0 comments on commit 1fd0216

Please sign in to comment.