Commit 21b41bec authored by Russ Cox's avatar Russ Cox

test and fix http redirect handling

BUG=2197242
R=r
DELTA=16  (16 added, 0 deleted, 0 changed)
OCL=35878
CL=35882
parent 36ccbbdf
......@@ -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;
......
......@@ -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)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment