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
This commit is contained in:
Dave Cheney 2012-10-31 02:24:08 +11:00
parent 71d9e956a0
commit be6afde348

View File

@ -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