mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-03-10 00:13:36 +08:00
fix: 修复空响应时无法正确反序列化的问题
This commit is contained in:
@@ -128,9 +128,9 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
where T : WechatOpenAIThirdPartyResponse, new()
|
||||
{
|
||||
byte[] bytes = await flurlResponse.GetBytesAsync().ConfigureAwait(false);
|
||||
bool jsonable = bytes.Length > 1 &&
|
||||
(bytes[0] == 91 && bytes[bytes.Length - 1] == 93) || // "[...]"
|
||||
(bytes[0] == 123 && bytes[bytes.Length - 1] == 125); // "{...}"
|
||||
bool jsonable =
|
||||
(bytes.Length > 1 && bytes[0] == 91 && bytes[bytes.Length - 1] == 93) || // "[...]"
|
||||
(bytes.Length > 1 && bytes[0] == 123 && bytes[bytes.Length - 1] == 125); // "{...}"
|
||||
|
||||
T result = jsonable ? JsonSerializer.Deserialize<T>(Encoding.UTF8.GetString(bytes)) : new T();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user