summaryrefslogtreecommitdiff
path: root/misc/dashboard
diff options
context:
space:
mode:
authorDave Cheney <dave@cheney.net>2012-10-31 02:24:08 +1100
committerDave Cheney <dave@cheney.net>2012-10-31 02:24:08 +1100
commitcbe209bdd0a1d0c5930c1fc879b6dd5427f4b651 (patch)
treebe841d7905580ef57f66e5b7222fc039f24c5aa3 /misc/dashboard
parent4136e244cf71e762ae6cc6fe625ac2df13caca2f (diff)
downloadgo-cbe209bdd0a1d0c5930c1fc879b6dd5427f4b651.tar.gz
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 http://codereview.appspot.com/6775066
Diffstat (limited to 'misc/dashboard')
-rw-r--r--misc/dashboard/builder/http.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/misc/dashboard/builder/http.go b/misc/dashboard/builder/http.go
index e50ae5724..b50e84551 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