From b3e8d9ccf3b548347e828b2cabffd4eebd475a7c Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Tue, 23 Feb 2021 18:56:18 -0500 Subject: [PATCH] client: Clarify usage of contexts --- client.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 44191c6..5d7e4f5 100644 --- a/client.go +++ b/client.go @@ -30,8 +30,9 @@ type Client struct { } // Get sends a Gemini request for the given URL. -// If the provided context is canceled or times out, the request -// is aborted and the context's error is returned. +// The context controls the entire lifetime of a request and its response: +// obtaining a connection, sending the request, and reading the response +// header and body. // // An error is returned if there was a Gemini protocol error. // A non-2x status code doesn't cause an error. @@ -48,15 +49,14 @@ func (c *Client) Get(ctx context.Context, url string) (*Response, error) { } // Do sends a Gemini request and returns a Gemini response. -// If the provided context is canceled or times out, the request -// is aborted and the context's error is returned. +// The context controls the entire lifetime of a request and its response: +// obtaining a connection, sending the request, and reading the response +// header and body. // // An error is returned if there was a Gemini protocol error. // A non-2x status code doesn't cause an error. // // If the returned error is nil, the user is expected to close the Response. -// -// Generally Get will be used instead of Do. func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) { if ctx == nil { panic("nil context")