Skip to content

Commit

Permalink
httpclient内存泄漏
Browse files Browse the repository at this point in the history
  • Loading branch information
my6521 committed Mar 17, 2024
1 parent be90178 commit 56839c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
29 changes: 15 additions & 14 deletions src/WWB.Paylink.BaoFooPay/BaoFooPayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@ public async Task<TResponse> ExecuteAsync<TResponse>(IBaoFooPayRequest<TResponse
//获取提交类型
var contentType = request.GetContentType();

var client = _httpClientFactory.CreateClient(Name);

var (body, isSuccessStatusCode) = await client.PostAsync(url, contentType, txtParams);

if (isSuccessStatusCode)
using (var client = _httpClientFactory.CreateClient(Name))
{
var rootResult = JsonConvert.DeserializeObject<TResponse>(body);
CheckResponseSign(rootResult, options);
rootResult.PrimaryHandler();
var (body, isSuccessStatusCode) = await client.PostAsync(url, contentType, txtParams);

return rootResult;
}
if (isSuccessStatusCode)
{
var rootResult = JsonConvert.DeserializeObject<TResponse>(body);
CheckResponseSign(rootResult, options);
rootResult.PrimaryHandler();

var result = Activator.CreateInstance<TResponse>();
result.ErrorCode = "SYSTEM_INNER_ERROR";
result.ErrorMsg = body;
return rootResult;
}

return result;
var result = Activator.CreateInstance<TResponse>();
result.ErrorCode = "SYSTEM_INNER_ERROR";
result.ErrorMsg = body;

return result;
}
}

private void VerifyOptions(BaoFooPayOptions options)
Expand Down
2 changes: 1 addition & 1 deletion src/WWB.Paylink.BaoFooPay/WWB.Paylink.BaoFooPay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>WWB.Paylink.BaoFooPay</PackageId>
<Version>1.0.5</Version>
<Version>1.0.6</Version>
<Authors>my6521</Authors>
<Description>惠收钱SDK。</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
8 changes: 5 additions & 3 deletions src/WWB.Paylink.Utility/Security/RSAUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public static string SignByPfx(string encryptStr, string pfxPath, string priKeyP
return Sign(Encoding.UTF8.GetBytes(encryptStr), privateKey);
}


/// <summary>
/// 公钥加签
/// </summary>
Expand All @@ -130,9 +129,11 @@ public static string SignByCer(string encryptStr, string pubCerPath)
var publicKey = RsaReadUtil.GetPublicKeyFromFile(pubCerPath);
return Sign(Encoding.UTF8.GetBytes(encryptStr), publicKey);
}
#endregion

#endregion 加签

#region 验签

/// <summary>
/// 公钥验签
/// </summary>
Expand All @@ -159,7 +160,8 @@ public static bool VerifyByPfx(string pfxPath, string priKeyPass, string encrypt
var publicKey = RsaReadUtil.GetPrivateKeyFromFile(pfxPath, priKeyPass);
return Verify(Encoding.UTF8.GetBytes(encryptStr), publicKey, signature);
}
#endregion

#endregion 验签

#region Private Methods

Expand Down

0 comments on commit 56839c2

Please sign in to comment.