]> Cypherpunks repositories - gostls13.git/commitdiff
misc/dashboard/builder: check http status before processing response
authorDave Cheney <dave@cheney.net>
Tue, 30 Oct 2012 15:24:08 +0000 (02:24 +1100)
committerDave Cheney <dave@cheney.net>
Tue, 30 Oct 2012 15:24:08 +0000 (02:24 +1100)
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

index e50ae572410011487d63e94b73fa70b6cc7ec1b9..b50e84551ba7534bc7c082a142208e32692e0783 100644 (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