diff options
| author | Russ Cox <rsc@golang.org> | 2009-10-19 12:10:14 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2009-10-19 12:10:14 -0700 |
| commit | cab57da1ba0c179db389cc14ddf690911d574bf5 (patch) | |
| tree | 7a7d06f244325548dda2a15cec560350964161d8 | |
| parent | f277a7a50eeeca98c8083d4f8ccc84c90e9581c4 (diff) | |
| download | golang-cab57da1ba0c179db389cc14ddf690911d574bf5.tar.gz | |
test and fix http redirect handling
BUG=2197242
R=r
DELTA=16 (16 added, 0 deleted, 0 changed)
OCL=35878
CL=35882
| -rw-r--r-- | src/pkg/http/client.go | 1 | ||||
| -rw-r--r-- | src/pkg/http/request_test.go | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/pkg/http/client.go b/src/pkg/http/client.go index 6ac602f27..698c5c7f4 100644 --- a/src/pkg/http/client.go +++ b/src/pkg/http/client.go @@ -198,6 +198,7 @@ func Get(url string) (r *Response, finalURL string, err os.Error) { err = os.ErrorString(fmt.Sprintf("%d response missing Location header", r.StatusCode)); break; } + continue; } finalURL = url; return; diff --git a/src/pkg/http/request_test.go b/src/pkg/http/request_test.go index 94da01521..7bddda3db 100644 --- a/src/pkg/http/request_test.go +++ b/src/pkg/http/request_test.go @@ -100,3 +100,18 @@ func TestPostContentTypeParsing(t *testing.T) { } } } + +func TestRedirect(t *testing.T) { + const ( + start = "http://codesearch.google.com/"; + end = "http://www.google.com/codesearch"; + ) + r, url, err := Get(start); + if err != nil { + t.Fatal(err); + } + r.Body.Close(); + if r.StatusCode != 200 || url != end { + t.Fatalf("Get(%s) got status %d at %s, want 200 at %s", start, r.StatusCode, url, end) + } +} |
