aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2015-12-09 17:07:44 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2015-12-09 17:35:43 +0000
commitefc806e92e9f7d591b31cdd0db4df4e626323d01 (patch)
tree090b0196a65f7d84730c6b8f5468d5c476374610 /src
parent7e1791b97f53bd42808ef2d2e783134b9c3de257 (diff)
downloadgo-efc806e92e9f7d591b31cdd0db4df4e626323d01.tar.xz
net/http: clarify some RoundTripper behaviors
Fixes #12796 Updates #13444 Change-Id: I56840c0baf9b32a683086a80f5db1c5ea0a7aedf Reviewed-on: https://go-review.googlesource.com/17680 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/net/http/client.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/net/http/client.go b/src/net/http/client.go
index 3a8b284859..c3f849e962 100644
--- a/src/net/http/client.go
+++ b/src/net/http/client.go
@@ -83,19 +83,26 @@ var DefaultClient = &Client{}
// goroutines.
type RoundTripper interface {
// RoundTrip executes a single HTTP transaction, returning
- // the Response for the request req. RoundTrip should not
- // attempt to interpret the response. In particular,
- // RoundTrip must return err == nil if it obtained a response,
- // regardless of the response's HTTP status code. A non-nil
- // err should be reserved for failure to obtain a response.
- // Similarly, RoundTrip should not attempt to handle
- // higher-level protocol details such as redirects,
+ // a Response for the provided Request.
+ //
+ // RoundTrip should not attempt to interpret the response. In
+ // particular, RoundTrip must return err == nil if it obtained
+ // a response, regardless of the response's HTTP status code.
+ // A non-nil err should be reserved for failure to obtain a
+ // response. Similarly, RoundTrip should not attempt to
+ // handle higher-level protocol details such as redirects,
// authentication, or cookies.
//
// RoundTrip should not modify the request, except for
- // consuming and closing the Body, including on errors. The
- // request's URL and Header fields are guaranteed to be
- // initialized.
+ // consuming and closing the Request's Body.
+ //
+ // RoundTrip must always close the body, including on errors,
+ // but depending on the implementation may do so in a separate
+ // goroutine even after RoundTrip returns. This means that
+ // callers wanting to reuse the body for subsequent requests
+ // must arrange to wait for the Close call before doing so.
+ //
+ // The Request's URL and Header fields must be initialized.
RoundTrip(*Request) (*Response, error)
}