Skip to content

Commit 833a251

Browse files
committed
升级依赖包版本并优化HTTP请求逻辑
升级多个项目文件中的NuGet包版本,包括`Microsoft.Net.Http.Headers`和`Microsoft.AspNetCore`相关包,以支持.NET 8.0框架。移除不再需要的旧版本引用。在`RequestUtility.Post.cs`中,新增`RequestUtility`静态类,并优化HTTP请求处理逻辑。此更改旨在提高兼容性和稳定性。
1 parent 657694e commit 833a251

File tree

7 files changed

+7
-20
lines changed

7 files changed

+7
-20
lines changed

Sample/Senparc.CO2NET.Sample.Consoles/Senparc.CO2NET.Sample.Consoles.Net8.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
2626
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
2727
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
28-
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
28+
<PackageReference Include="Microsoft.Net.Http.Headers" Version="8.0.0" />
2929

3030
<!--<FrameworkReference Include="Microsoft.AspNetCore.App" />-->
3131

src/Senparc.CO2NET.AspNet/Senparc.CO2NET.AspNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@
8686
<!--<ItemGroup Condition="('$(TargetFramework)' == 'netstandard2.0') OR ('$(TargetFramework)' == 'netstandard2.1')">-->
8787
<ItemGroup Condition="'$(TargetFramework)' != 'net462' And '$(TargetFramework)' != 'net8.0'">
8888
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions">
89-
<Version>2.2.0</Version>
89+
<Version>2.3.0</Version>
9090
</PackageReference>
9191
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions">
92-
<Version>2.2.0</Version>
92+
<Version>2.3.0</Version>
9393
</PackageReference>
9494
</ItemGroup>
9595
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">

src/Senparc.CO2NET.Cache.CsRedis.Tests/Senparc.CO2NET.Cache.CsRedis.Tests.net8.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
3131
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
3232
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
33-
34-
<PackageReference Include="Microsoft.Net.Http.Headers">
35-
<Version>2.2.8</Version>
36-
</PackageReference>
3733
</ItemGroup>
3834

3935
<ItemGroup>

src/Senparc.CO2NET.Cache.Redis.Tests/Senparc.CO2NET.Cache.Redis.Tests.net8.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
3131
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
3232
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
33-
34-
<PackageReference Include="Microsoft.Net.Http.Headers">
35-
<Version>2.2.8</Version>
36-
</PackageReference>
3733
</ItemGroup>
3834

3935
<ItemGroup>

src/Senparc.CO2NET.Tests/Senparc.CO2NET.Tests.net8.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333
<PackageReference Include="Moq" Version="4.20.69" />
3434
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
3535
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
36-
37-
<PackageReference Include="Microsoft.Net.Http.Headers">
38-
<Version>2.2.8</Version>
39-
</PackageReference>
40-
4136
</ItemGroup>
4237

4338
<ItemGroup>

src/Senparc.CO2NET/Senparc.CO2NET.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
220220
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
221221
<PackageReference Include="Microsoft.Net.Http.Headers" Version="8.0.0" Condition=" '$(TargetFramework)' == 'net8.0'" />
222-
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.0" Condition=" '$(TargetFramework)' != 'net8.0'" />
222+
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.3.4" Condition=" '$(TargetFramework)' != 'net8.0'" />
223223
</ItemGroup>
224224
<ItemGroup>
225225
<Folder Include="Utilities\HttpUtility\HttpPut\" />

src/Senparc.CO2NET/Utilities/HttpUtility/HttpPost/RequestUtility.Post.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ and limitations under the License.
8989
#endif
9090

9191
namespace Senparc.CO2NET.HttpUtility
92-
{
92+
{
9393
/// <summary>
9494
/// HTTP 请求工具类
9595
/// </summary>
@@ -388,6 +388,8 @@ public static HttpWebRequest HttpPost_Common_Net45(string url, string method, Co
388388
}
389389
else
390390
{
391+
postStream.Seek(0, SeekOrigin.Begin);
392+
391393
if (postStream.Length > 0)
392394
{
393395
if (hasFormData)
@@ -404,8 +406,6 @@ public static HttpWebRequest HttpPost_Common_Net45(string url, string method, Co
404406
//contentType = "application/x-www-form-urlencoded";
405407
}
406408

407-
postStream.Seek(0, SeekOrigin.Begin);
408-
409409
hc = new StreamContent(postStream);
410410

411411
contentType ??= HttpClientHelper.DEFAULT_CONTENT_TYPE;

0 commit comments

Comments
 (0)