summaryrefslogtreecommitdiff
path: root/finger
diff options
context:
space:
mode:
Diffstat (limited to 'finger')
-rw-r--r--finger/client.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/finger/client.go b/finger/client.go
index 0488b79..f89a788 100644
--- a/finger/client.go
+++ b/finger/client.go
@@ -2,6 +2,7 @@ package finger
import (
"bytes"
+ "context"
"errors"
"io"
"net"
@@ -18,7 +19,7 @@ import (
type Client struct{}
// RoundTrip sends a single finger request and returns its response.
-func (c Client) RoundTrip(request *types.Request) (*types.Response, error) {
+func (c Client) RoundTrip(ctx context.Context, request *types.Request) (*types.Response, error) {
if request.Scheme != "finger" && request.Scheme != "" {
return nil, errors.New("non-finger protocols not supported")
}
@@ -28,7 +29,7 @@ func (c Client) RoundTrip(request *types.Request) (*types.Response, error) {
host = net.JoinHostPort(host, "79")
}
- conn, err := net.Dial("tcp", host)
+ conn, err := (&net.Dialer{}).DialContext(ctx, "tcp", host)
if err != nil {
return nil, err
}
@@ -55,12 +56,12 @@ func (c Client) RoundTrip(request *types.Request) (*types.Response, error) {
}
// Fetch resolves a finger query.
-func (c Client) Fetch(query string) (*types.Response, error) {
+func (c Client) Fetch(ctx context.Context, query string) (*types.Response, error) {
req, err := ParseRequest(bytes.NewBufferString(query + "\r\n"))
if err != nil {
return nil, err
}
- return c.RoundTrip(req)
+ return c.RoundTrip(ctx, req)
}
func (c Client) IsRedirect(_ *types.Response) bool { return false }