fix: ignore wangsu api responses without content

This commit is contained in:
Fu Diwei 2025-04-18 17:54:51 +08:00
parent 7329a22132
commit eb45b56a87

View File

@ -178,9 +178,12 @@ func (c *Client) SendRequestWithResult(method string, path string, params interf
return resp, err return resp, err
} }
if err := json.Unmarshal(resp.Body(), &result); err != nil { respBody := resp.Body()
if len(respBody) != 0 {
if err := json.Unmarshal(respBody, &result); err != nil {
return resp, fmt.Errorf("wangsu api error: failed to parse response: %w", err) return resp, fmt.Errorf("wangsu api error: failed to parse response: %w", err)
} }
}
result.SetRequestId(resp.Header().Get("x-cnc-request-id")) result.SetRequestId(resp.Header().Get("x-cnc-request-id"))
return resp, nil return resp, nil