From 420f01da2a59b5f42a6ed471d3df7b28cbc5e79d Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Sun, 21 Feb 2021 16:47:53 -0500 Subject: [PATCH] client: Remove Timeout Clients should use context.WithTimeout instead. --- client.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/client.go b/client.go index 97a35bb..d9a0718 100644 --- a/client.go +++ b/client.go @@ -23,14 +23,6 @@ type Client struct { // See the tofu submodule for an implementation of trust on first use. TrustCertificate func(hostname string, cert *x509.Certificate) error - // Timeout specifies a time limit for requests made by this - // Client. The timeout includes connection time and reading - // the response body. The timer remains running after - // Get or Do return and will interrupt reading of the Response.Body. - // - // A Timeout of zero means no timeout. - Timeout time.Duration - // DialContext specifies the dial function for creating TCP connections. // If DialContext is nil, the client dials using package net. DialContext func(ctx context.Context, network, addr string) (net.Conn, error) @@ -101,17 +93,11 @@ func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) { addr := net.JoinHostPort(host, port) // Connect to the host - start := time.Now() conn, err := c.dialContext(ctx, "tcp", addr) if err != nil { return nil, err } - // Set the connection deadline - if c.Timeout != 0 { - conn.SetDeadline(start.Add(c.Timeout)) - } - // Setup TLS conn = tls.Client(conn, &tls.Config{ InsecureSkipVerify: true, @@ -173,9 +159,7 @@ func (c *Client) dialContext(ctx context.Context, network, addr string) (net.Con if c.DialContext != nil { return c.DialContext(ctx, network, addr) } - return (&net.Dialer{ - Timeout: c.Timeout, - }).DialContext(ctx, network, addr) + return (&net.Dialer{}).DialContext(ctx, network, addr) } func (c *Client) verifyConnection(cs tls.ConnectionState, hostname string) error {