From: Dave Cheney Date: Tue, 30 Oct 2012 15:24:08 +0000 (+1100) Subject: misc/dashboard/builder: check http status before processing response X-Git-Tag: go1.1rc2~2034 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=be6afde348db68dfc9f59f57cbb15ed637158ac0;p=gostls13.git misc/dashboard/builder: check http status before processing response Occasionally GAE will return a 500 error response, don't treat this as a valid JSON body. R=adg, dsymonds CC=golang-dev https://golang.org/cl/6775066 --- diff --git a/misc/dashboard/builder/http.go b/misc/dashboard/builder/http.go index e50ae57241..b50e84551b 100644 --- a/misc/dashboard/builder/http.go +++ b/misc/dashboard/builder/http.go @@ -56,8 +56,10 @@ func dash(meth, cmd string, args url.Values, req, resp interface{}) error { if err != nil { return err } - defer r.Body.Close() + if r.StatusCode != http.StatusOK { + return fmt.Errorf("bad http response: %v", r.Status) + } body := new(bytes.Buffer) if _, err := body.ReadFrom(r.Body); err != nil { return err