]> Cypherpunks repositories - gostls13.git/commitdiff
http: document http client/transport thread safety
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 16 Jun 2011 22:02:47 +0000 (15:02 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 16 Jun 2011 22:02:47 +0000 (15:02 -0700)
Fixes #1961

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/4633045

src/pkg/http/client.go

index 9478cfae1db24d2cb98adc10d99714bd6cb4f636..2883b0493d7700998427eb5416857c6e9b4dba2d 100644 (file)
@@ -16,6 +16,11 @@ import (
 
 // A Client is an HTTP client. Its zero value (DefaultClient) is a usable client
 // that uses DefaultTransport.
+//
+// The Client's Transport typically has internal state (cached
+// TCP connections), so Clients should be reused instead of created as
+// needed. Clients are safe for concurrent use by multiple goroutines.
+//
 // Client is not yet very configurable.
 type Client struct {
        Transport RoundTripper // if nil, DefaultTransport is used
@@ -36,6 +41,9 @@ var DefaultClient = &Client{}
 
 // RoundTripper is an interface representing the ability to execute a
 // single HTTP transaction, obtaining the Response for a given Request.
+//
+// A RoundTripper must be safe for concurrent use by multiple
+// goroutines.
 type RoundTripper interface {
        // RoundTrip executes a single HTTP transaction, returning
        // the Response for the request req.  RoundTrip should not