Explorar o código

fix unmarshal when receive empty body

yixiong.jxy %!s(int64=7) %!d(string=hai) anos
pai
achega
07f44894c0
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  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)