Sfoglia il codice sorgente

fix unmarshal when receive empty body

yixiong.jxy 7 anni fa
parent
commit
07f44894c0
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  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)