From be6afde348db68dfc9f59f57cbb15ed637158ac0 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Wed, 31 Oct 2012 02:24:08 +1100 Subject: [PATCH] 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 --- misc/dashboard/builder/http.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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