Rev 23: http/client: Don't put []byte arrays in error messages. in http://bazaar.launchpad.net/+branch/goose

John Arbash Meinel john at arbash-meinel.com
Mon Nov 26 11:11:48 UTC 2012


At http://bazaar.launchpad.net/+branch/goose

------------------------------------------------------------
revno: 23 [merge]
revision-id: john at arbash-meinel.com-20121126111139-42s7ravmctpscybu
parent: ian.booth at canonical.com-20121126021121-s0sguqccyik0lqc3
parent: john at arbash-meinel.com-20121125115343-j1oag9szrg0jmute
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: goose
timestamp: Mon 2012-11-26 11:11:39 +0000
message:
  http/client: Don't put []byte arrays in error messages.
modified:
  http/client.go                 go.go-20121120112238-gw4zuxlm0qixyco7-1
-------------- next part --------------
=== modified file 'http/client.go'
--- a/http/client.go	2012-11-22 07:33:43 +0000
+++ b/http/client.go	2012-11-25 11:53:43 +0000
@@ -168,11 +168,12 @@
 	if !foundStatus && len(expectedStatus) > 0 {
 		defer rawResp.Body.Close()
 		var errInfo interface{}
-		errInfo, _ = ioutil.ReadAll(rawResp.Body)
+		errBytes, _ := ioutil.ReadAll(rawResp.Body)
+		errInfo = string(errBytes)
 		// Check if we have a JSON representation of the failure, if so decode it.
 		if rawResp.Header.Get("Content-Type") == "application/json" {
 			var wrappedErr ErrorWrapper
-			if err := json.Unmarshal(errInfo.([]byte), &wrappedErr); err == nil {
+			if err := json.Unmarshal(errBytes, &wrappedErr); err == nil {
 				errInfo = wrappedErr.Error
 			}
 		}



More information about the bazaar-commits mailing list