Merge pull request #13 from ukai/fix_http

Close body even if it got error http status.
This commit is contained in:
Andrew Gerrand 2013-08-29 17:26:52 -07:00
commit df73e837ff

View File

@ -174,10 +174,10 @@ func (h *httpGetter) Get(context Context, in *pb.GetRequest, out *pb.GetResponse
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return fmt.Errorf("server returned: %v", res.Status)
}
defer res.Body.Close()
// TODO: avoid this garbage.
b, err := ioutil.ReadAll(res.Body)
if err != nil {