mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 23:13:32 +08:00
fix: 修复空响应时无法正确反序列化的问题
This commit is contained in:
parent
66c9731d07
commit
7b0c793ae7
@ -122,9 +122,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads
|
||||
where T : WechatAdsResponse, 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();
|
||||
|
||||
|
@ -111,9 +111,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
where T : WechatApiResponse, 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();
|
||||
|
||||
|
@ -151,9 +151,9 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
where T : WechatOpenAIPlatformResponse, 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();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -149,9 +149,9 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
where T : WechatTenpayResponse, 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();
|
||||
|
||||
result.RawStatus = flurlResponse.StatusCode;
|
||||
|
@ -112,9 +112,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
where T : WechatWorkResponse, 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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user