net/http: add missing error checking reading trailers

This is a simplified version of earlier versions of this CL
and now only fixes obviously incorrect things, without
changing the locking on bodyEOFReader.

I'd like to see if this is sufficient before changing the
locking.

Update #4191

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/6739055
This commit is contained in:
Brad Fitzpatrick 2012-11-13 22:38:25 -08:00
parent aa38801788
commit 56bcef02fc
4 changed files with 59 additions and 7 deletions

View file

@ -219,6 +219,9 @@ func TestRedirects(t *testing.T) {
return checkErr
}}
res, err := c.Get(ts.URL)
if err != nil {
t.Fatalf("Get error: %v", err)
}
finalUrl := res.Request.URL.String()
if e, g := "<nil>", fmt.Sprintf("%v", err); e != g {
t.Errorf("with custom client, expected error %q, got %q", e, g)
@ -335,7 +338,10 @@ func TestRedirectCookiesJar(t *testing.T) {
c.Jar = &TestJar{perURL: make(map[string][]*Cookie)}
u, _ := url.Parse(ts.URL)
c.Jar.SetCookies(u, []*Cookie{expectedCookies[0]})
resp, _ := c.Get(ts.URL)
resp, err := c.Get(ts.URL)
if err != nil {
t.Fatalf("Get: %v", err)
}
matchReturnedCookies(t, expectedCookies, resp.Cookies())
}