diff options
| author | Adnan Maolood <[email protected]> | 2021-02-21 16:47:53 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-21 16:47:56 -0500 |
| commit | 420f01da2a59b5f42a6ed471d3df7b28cbc5e79d (patch) | |
| tree | 2c0d000a15dc91cbac788866d33957074f0e1732 /client.go | |
| parent | Move Flush back to ResponseWriter (diff) | |
| download | go-gemini-420f01da2a59b5f42a6ed471d3df7b28cbc5e79d.tar.xz go-gemini-420f01da2a59b5f42a6ed471d3df7b28cbc5e79d.zip | |
client: Remove Timeout
Clients should use context.WithTimeout instead.
Diffstat (limited to 'client.go')
| -rw-r--r-- | client.go | 18 |
1 files changed, 1 insertions, 17 deletions
@@ -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 { |