aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-12-17 17:16:55 -0500
committerAdnan Maolood <[email protected]>2020-12-17 17:16:55 -0500
commit176b260468e9d586d79b55d853289bc3e87785dd (patch)
treede2f130723e92d0ce9b6efc2a0625d7faaa67105 /client.go
parentFix locking up of KnownHostsFile and CertificateDir (diff)
downloadgo-gemini-176b260468e9d586d79b55d853289bc3e87785dd.tar.xz
go-gemini-176b260468e9d586d79b55d853289bc3e87785dd.zip
Allow Request.Context to be nil
Diffstat (limited to 'client.go')
-rw-r--r--client.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/client.go b/client.go
index 21a5c4f..6821ded 100644
--- a/client.go
+++ b/client.go
@@ -2,6 +2,7 @@ package gemini
import (
"bufio"
+ "context"
"crypto/tls"
"crypto/x509"
"errors"
@@ -96,7 +97,12 @@ func (c *Client) do(req *Request, via []*Request) (*Response, error) {
},
ServerName: hostname,
}
- netConn, err := (&net.Dialer{}).DialContext(req.Context, "tcp", req.Host)
+
+ ctx := req.Context
+ if ctx == nil {
+ ctx = context.Background()
+ }
+ netConn, err := (&net.Dialer{}).DialContext(ctx, "tcp", req.Host)
if err != nil {
return nil, err
}