瀏覽代碼

fix unmarshal when receive empty body

yixiong.jxy 7 年之前
父節點
當前提交
07f44894c0
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      sdk/responses/response.go

+ 5 - 0
sdk/responses/response.go

@@ -47,6 +47,11 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
 		// common response need not unmarshal
 		return
 	}
+
+	if len(response.GetHttpContentBytes()) == 0 {
+		return
+	}
+
 	if strings.ToUpper(format) == "JSON" {
 		initJsonParserOnce()
 		err = jsonParser.Unmarshal(response.GetHttpContentBytes(), response)