]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: fix doc inaccuracy and typo; tighten test
authorBrad Fitzpatrick <bradfitz@golang.org>
Sun, 24 Jun 2012 17:41:12 +0000 (10:41 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 24 Jun 2012 17:41:12 +0000 (10:41 -0700)
Note url.Error wrapping, and s/issue/issuing/.

Fixes #3724

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6294093

src/pkg/net/http/client.go
src/pkg/net/http/client_test.go

index fba775fddc31226fe23dccf14c19598a51ddad2f..89441424e1d8829dbeb757a1afbc4d81bdfd12ed 100644 (file)
@@ -36,7 +36,8 @@ type Client struct {
        // following an HTTP redirect. The arguments req and via
        // are the upcoming request and the requests made already,
        // oldest first. If CheckRedirect returns an error, the client
-       // returns that error instead of issue the Request req.
+       // returns that error (wrapped in a url.Error) instead of
+       // issuing the Request req.
        //
        // If CheckRedirect is nil, the Client uses its default policy,
        // which is to stop after 10 consecutive requests.
index e2a08204e08ff60fd3471b43f9aa683a3d714160..fe4b626a31e97c2e5357a74ae3024f284cc0a060 100644 (file)
@@ -231,8 +231,8 @@ func TestRedirects(t *testing.T) {
 
        checkErr = errors.New("no redirects allowed")
        res, err = c.Get(ts.URL)
-       if e, g := "Get /?n=1: no redirects allowed", fmt.Sprintf("%v", err); e != g {
-               t.Errorf("with redirects forbidden, expected error %q, got %q", e, g)
+       if urlError, ok := err.(*url.Error); !ok || urlError.Err != checkErr {
+               t.Errorf("with redirects forbidden, expected a *url.Error with our 'no redirects allowed' error inside; got %#v (%q)", err, err)
        }
 }